1
0
Fork 0
forked from 2sys/shoutdotdev

add frontend_host config variable

This commit is contained in:
Brent Schroeter 2025-04-11 23:22:04 -07:00
parent 2c15cdfd11
commit 7893aa65e3
2 changed files with 14 additions and 3 deletions

View file

@ -38,7 +38,10 @@ pub fn new_oauth_client(settings: &Settings) -> Result<BasicClient> {
), ),
) )
.set_redirect_uri( .set_redirect_uri(
RedirectUrl::new(settings.auth.redirect_url.clone()) RedirectUrl::new(format!(
"{}{}/auth/callback",
settings.frontend_host, settings.base_path
))
.context("failed to create new redirection URL")?, .context("failed to create new redirection URL")?,
)) ))
} }

View file

@ -8,20 +8,29 @@ use crate::app_state::AppState;
#[derive(Clone, Debug, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct Settings { pub struct Settings {
/// Prefix under which to nest all routes. If specified, include leading
/// slash but no trailing slash, for example "/app". For default behavior,
/// leave as empty string.
#[serde(default)] #[serde(default)]
pub base_path: String, pub base_path: String,
/// postgresql:// URL.
pub database_url: String, pub database_url: String,
/// When set to 1, embedded Diesel migrations will be run on startup. /// When set to 1, embedded Diesel migrations will be run on startup.
pub run_database_migrations: Option<u8>, pub run_database_migrations: Option<u8>,
/// Address for server to bind to
#[serde(default = "default_host")] #[serde(default = "default_host")]
pub host: String, pub host: String,
/// Port for server to bind to
#[serde(default = "default_port")] #[serde(default = "default_port")]
pub port: u16, pub port: u16,
/// Host visible to end users, for example "https://shout.dev"
pub frontend_host: String,
pub auth: AuthSettings, pub auth: AuthSettings,
pub email: EmailSettings, pub email: EmailSettings,
@ -39,7 +48,6 @@ fn default_host() -> String {
pub struct AuthSettings { pub struct AuthSettings {
pub client_id: String, pub client_id: String,
pub client_secret: String, pub client_secret: String,
pub redirect_url: String,
pub auth_url: String, pub auth_url: String,
pub token_url: String, pub token_url: String,
pub userinfo_url: String, pub userinfo_url: String,