Update config keys, add port
This commit is contained in:
parent
03bcb4df90
commit
d8b79ae852
4 changed files with 20 additions and 12 deletions
|
@ -1,4 +1,5 @@
|
||||||
padlock_secret = ""
|
padlock-secret = ""
|
||||||
|
port = 80
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
connection_string = "sqlite://sqlite.db"
|
connection-string = "sqlite://sqlite.db"
|
||||||
|
|
|
@ -3,27 +3,32 @@ use serde::Deserialize;
|
||||||
use crate::secrets::PadlockGenerationSecret;
|
use crate::secrets::PadlockGenerationSecret;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
database: DatabaseConfig,
|
|
||||||
#[serde(default)]
|
|
||||||
auth_backends: Vec<AuthBackend>,
|
|
||||||
#[serde(with = "hex::serde")]
|
#[serde(with = "hex::serde")]
|
||||||
padlock_secret: PadlockGenerationSecret,
|
pub padlock_secret: PadlockGenerationSecret,
|
||||||
|
pub port: u16,
|
||||||
|
|
||||||
|
pub database: DatabaseConfig,
|
||||||
|
#[serde(default)]
|
||||||
|
pub auth_backends: Vec<AuthBackendConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct DatabaseConfig {
|
pub struct DatabaseConfig {
|
||||||
connection_string: String,
|
pub connection_string: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
pub enum AuthBackend {
|
pub enum AuthBackendConfig {
|
||||||
#[serde(rename = "LDAP")]
|
#[serde(rename = "LDAP")]
|
||||||
Ldap(LdapBackendConfig),
|
Ldap(LdapBackendConfig),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct LdapBackendConfig {
|
pub struct LdapBackendConfig {
|
||||||
server_address: String,
|
pub server_address: String,
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
let config = load_config(&args.config).await?;
|
let config = load_config(&args.config).await?;
|
||||||
|
|
||||||
tokio::spawn(server::run()).await??;
|
tokio::spawn(server::run(config.port)).await??;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::net::Ipv6Addr;
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::Query,
|
extract::Query,
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
|
@ -13,7 +15,7 @@ use crate::auth::{AuthenticationError, UserServerKeyGenerator};
|
||||||
use crate::secrets::{Password, ServerHash, UserToken};
|
use crate::secrets::{Password, ServerHash, UserToken};
|
||||||
|
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub async fn run() -> color_eyre::Result<()> {
|
pub async fn run(port: u16) -> color_eyre::Result<()> {
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/tls-check/success", get(|| async { "OK" }))
|
.route("/tls-check/success", get(|| async { "OK" }))
|
||||||
.route("/api-login", post(api_login))
|
.route("/api-login", post(api_login))
|
||||||
|
@ -21,7 +23,7 @@ pub async fn run() -> color_eyre::Result<()> {
|
||||||
"/generate-user-server-key-2",
|
"/generate-user-server-key-2",
|
||||||
post(generate_user_server_key_2),
|
post(generate_user_server_key_2),
|
||||||
);
|
);
|
||||||
let listener = tokio::net::TcpListener::bind("[::]:8080").await?;
|
let listener = tokio::net::TcpListener::bind((Ipv6Addr::UNSPECIFIED, port)).await?;
|
||||||
axum::serve(listener, app).await?;
|
axum::serve(listener, app).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue