diff --git a/src/server/mod.rs b/src/server/mod.rs index 8077dab38c..f9eacd8aea 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -186,7 +186,7 @@ impl Server { max_size: settings.database_pool_max_size, ..Default::default() })); - let tokenserver_state = if settings.enable_tokenserver { + let tokenserver_state = if settings.tokenserver.enabled { Some(tokenserver::ServerState::from_settings( &settings.tokenserver, )?) diff --git a/src/settings.rs b/src/settings.rs index eba6cee4ca..1de94f2dd0 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -82,11 +82,6 @@ pub struct Settings { /// Settings specific to Tokenserver pub tokenserver: TokenserverSettings, - - // XXX: This is a temporary setting used to enable Tokenserver-related features. In - // the future, Tokenserver will always be enabled, and this setting will be - // removed. - pub enable_tokenserver: bool, } impl Default for Settings { @@ -114,7 +109,6 @@ impl Default for Settings { enforce_quota: false, spanner_emulator_host: None, tokenserver: TokenserverSettings::default(), - enable_tokenserver: false, } } } @@ -168,9 +162,10 @@ impl Settings { s.set_default("enforce_quota", false)?; // Set Tokenserver defaults - s.set_default("enable_tokenserver", false)?; - s.set_default("tokenserver.fxa_metrics_hash_secret", "secret")?; + s.set_default("tokenserver.database_url", "mysql://root@127.0.0.1/tokenserver")?; + s.set_default("tokenserver.enabled", false)?; s.set_default("tokenserver.fxa_email_domain", "test.com")?; + s.set_default("tokenserver.fxa_metrics_hash_secret", "secret")?; // Merge the config file if supplied if let Some(config_filename) = filename { diff --git a/src/tokenserver/settings.rs b/src/tokenserver/settings.rs index fde1cf26c7..f01744326b 100644 --- a/src/tokenserver/settings.rs +++ b/src/tokenserver/settings.rs @@ -3,11 +3,20 @@ use serde::Deserialize; #[derive(Clone, Debug, Deserialize)] pub struct Settings { pub database_url: String, + pub database_pool_max_size: Option, + // NOTE: Not supported by deadpool! pub database_pool_min_idle: Option, + /// Pool timeout when waiting for a slot to become available, in seconds pub database_pool_connection_timeout: Option, + + // XXX: This is a temporary setting used to enable Tokenserver-related features. In + // the future, Tokenserver will always be enabled, and this setting will be + // removed. + pub enabled: bool, + pub fxa_metrics_hash_secret: String, /// The email domain for users' FxA accounts. This should be set according to the @@ -25,6 +34,7 @@ impl Default for Settings { database_pool_max_size: None, database_pool_min_idle: None, database_pool_connection_timeout: Some(30), + enabled: false, fxa_email_domain: "api.accounts.firefox.com".to_owned(), fxa_metrics_hash_secret: "secret".to_owned(), fxa_oauth_server_url: None,