@@ -62,14 +62,15 @@ pub struct ConfigFile {
6262 pub request_url : String ,
6363 pub request_method : String ,
6464 pub request_data : Option < String > ,
65- pub request_content_type : String ,
65+ pub request_content_type : String ,
6666
67- pub webauthn_enable : bool ,
67+ pub webauthn_enable : bool ,
6868
69- // pub force_https_redirects: bool,
70-
71- pub users : Vec < User > ,
72- pub services : Services ,
69+ // pub force_https_redirects: bool,
70+ /// Path to a file containing the user definitions
71+ pub users_file : Option < String > ,
72+ pub users : Vec < User > ,
73+ pub services : Services ,
7374}
7475
7576impl Default for ConfigFile {
@@ -111,14 +112,15 @@ impl Default for ConfigFile {
111112 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 ( ) ) ,
112113 request_content_type : "application/x-www-form-urlencoded" . to_string ( ) ,
113114
114- webauthn_enable : true ,
115+ webauthn_enable : true ,
115116
116- // force_https_redirects: true,
117+ // force_https_redirects: true,
117118
118- users : vec ! [ ] ,
119- services : Services ( vec ! [ ] ) ,
120- }
121- }
119+ users_file : None ,
120+ users : vec ! [ ] ,
121+ services : Services ( vec ! [ ] ) ,
122+ }
123+ }
122124}
123125
124126impl ConfigFile {
@@ -150,11 +152,17 @@ impl ConfigFile {
150152 /// Note that live-updating the CONFIG_FILE environment variable
151153 /// is **NOT** supported
152154 pub async fn reload ( ) -> crate :: error:: Result < ( ) > {
153- let mut config = CONFIG . write ( ) . await ;
154- log:: info!( "Reloading config from {}" , CONFIG_FILE . as_str( ) ) ;
155- * config = serde_yaml:: from_str :: < ConfigFile > ( & std:: fs:: read_to_string ( CONFIG_FILE . as_str ( ) ) ?) ?;
156- Ok ( ( ) )
157- }
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+ }
158166
159167 /// Set up a file watcher that fires the [reload](ConfigFile::reload) method so
160168 /// that config file changes get automatically picked up
@@ -174,12 +182,22 @@ impl ConfigFile {
174182 } , watcher_config)
175183 . expect ( "Failed to create watcher for the config file" ) ;
176184
177- watcher
178- . watch ( Path :: new ( CONFIG_FILE . as_str ( ) ) , notify:: RecursiveMode :: NonRecursive )
179- . expect ( "Failed to watch config file for changes" ) ;
180-
181- watcher
182- }
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+ }
183201
184202 /// Read the SAML certificate from the [saml_cert_pem_path](ConfigFile::saml_cert_pem_path)
185203 /// filepath
0 commit comments