@@ -112,15 +112,16 @@ impl Default for ConfigFile {
112112 request_data : Some ( "to={email}&subject={title} Login&body=Click the link to login: <a href=\" {magic_link}\" >Login</a>&type=text/html" . to_string ( ) ) ,
113113 request_content_type : "application/x-www-form-urlencoded" . to_string ( ) ,
114114
115- webauthn_enable : true ,
115+ webauthn_enable : true ,
116116
117- // force_https_redirects: true,
117+ // force_https_redirects: true,
118118
119- users_file : None ,
120- users : vec ! [ ] ,
121- services : Services ( vec ! [ ] ) ,
122- }
119+ users_file : None ,
120+ users : vec ! [ ] ,
121+
122+ services : Services ( vec ! [ ] ) ,
123123 }
124+ }
124125}
125126
126127impl ConfigFile {
@@ -152,17 +153,17 @@ impl ConfigFile {
152153 /// Note that live-updating the CONFIG_FILE environment variable
153154 /// is **NOT** supported
154155 pub async fn reload ( ) -> crate :: error:: Result < ( ) > {
155- let mut config = CONFIG . write ( ) . await ;
156- log:: info!( "Reloading config from {}" , CONFIG_FILE . as_str( ) ) ;
157- let mut new_config =
158- serde_yaml:: from_str :: < ConfigFile > ( & std:: fs:: read_to_string ( CONFIG_FILE . as_str ( ) ) ?) ?;
159- if let Some ( users_file) = & new_config. users_file {
160- new_config. users =
161- serde_yaml:: from_str :: < Vec < User > > ( & std:: fs:: read_to_string ( users_file) ?) ?;
162- }
163- * config = new_config;
164- Ok ( ( ) )
165- }
156+ let mut config = CONFIG . write ( ) . await ;
157+ log:: info!( "Reloading config from {}" , CONFIG_FILE . as_str( ) ) ;
158+ let mut new_config =
159+ serde_yaml:: from_str :: < ConfigFile > ( & std:: fs:: read_to_string ( CONFIG_FILE . as_str ( ) ) ?) ?;
160+ if let Some ( users_file) = & new_config. users_file {
161+ new_config. users =
162+ serde_yaml:: from_str :: < Vec < User > > ( & std:: fs:: read_to_string ( users_file) ?) ?;
163+ }
164+ * config = new_config;
165+ Ok ( ( ) )
166+ }
166167
167168 /// Set up a file watcher that fires the [reload](ConfigFile::reload) method so
168169 /// that config file changes get automatically picked up
@@ -180,24 +181,24 @@ impl ConfigFile {
180181 }
181182 } )
182183 } , watcher_config)
183- . expect ( "Failed to create watcher for the config file" ) ;
184-
185- watcher
186- . watch ( Path :: new ( CONFIG_FILE . as_str ( ) ) , notify:: RecursiveMode :: NonRecursive )
187- . expect ( "Failed to watch config file for changes" ) ;
188-
189- if let Some ( users_file) = CONFIG
190- . try_read ( )
191- . ok ( )
192- . and_then ( |c| c. users_file . clone ( ) )
193- {
194- watcher
195- . watch ( Path :: new ( & users_file) , notify:: RecursiveMode :: NonRecursive )
196- . expect ( "Failed to watch users file for changes" ) ;
197- }
198-
199- watcher
200- }
184+ . expect ( "Failed to create watcher for the config file" ) ;
185+
186+ watcher
187+ . watch ( Path :: new ( CONFIG_FILE . as_str ( ) ) , notify:: RecursiveMode :: NonRecursive )
188+ . expect ( "Failed to watch config file for changes" ) ;
189+
190+ if let Some ( users_file) = CONFIG
191+ . try_read ( )
192+ . ok ( )
193+ . and_then ( |c| c. users_file . clone ( ) )
194+ {
195+ watcher
196+ . watch ( Path :: new ( & users_file) , notify:: RecursiveMode :: NonRecursive )
197+ . expect ( "Failed to watch users file for changes" ) ;
198+ }
199+
200+ watcher
201+ }
201202
202203 /// Read the SAML certificate from the [saml_cert_pem_path](ConfigFile::saml_cert_pem_path)
203204 /// filepath
@@ -214,14 +215,14 @@ impl ConfigFile {
214215 /// filepath
215216 pub fn get_saml_key ( & self ) -> Result < String , std:: io:: Error > {
216217 let data = std:: fs:: read_to_string ( & self . saml_key_pem_path ) ?;
217- Ok ( data
218- . lines ( )
219- . filter ( |line| {
220- !line. contains ( "BEGIN PRIVATE KEY" ) && !line. contains ( "END PRIVATE KEY" )
221- } )
222- . collect :: < String > ( )
223- . replace ( "\n " , "" ) )
224- }
218+ Ok ( data
219+ . lines ( )
220+ . filter ( |line| {
221+ !line. contains ( "BEGIN PRIVATE KEY" ) && !line. contains ( "END PRIVATE KEY" )
222+ } )
223+ . collect :: < String > ( )
224+ . replace ( "\n " , "" ) )
225+ }
225226}
226227
227228/// Basic key-value store database schema for some minor config values,
0 commit comments