Skip to content

Commit e709999

Browse files
author
Emily Ehlert
committed
backend: Fix OIDC setup logic
When a user tries to use the OIDC login endpoint and OIDC is not configured we try setting it up again (for example VaulTLS started before the OIDC server). When this is successful the logic was missing to actually use and store the new OIDC configuration. Reassign the new OIDC configuration to the OIDC settings variable. Fixes
1 parent fb415a6 commit e709999

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

backend/src/api.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,22 @@ pub(crate) async fn oidc_login(
211211
// OIDC is not active? Maybe it has since become available
212212
// Retry setting up OIDC
213213
let oidc_settings = state.settings.get_oidc();
214-
let oidc = match oidc_settings.auth_url.is_empty() {
215-
true => None,
216-
false => {
217-
debug!("OIDC enabled. Trying to connect to {}.", oidc_settings.auth_url);
218-
OidcAuth::new(&oidc_settings).await.ok()
219-
}
214+
let new_oidc = if !oidc_settings.auth_url.is_empty() {
215+
debug!("OIDC enabled. Trying to connect to {}.", oidc_settings.auth_url);
216+
OidcAuth::new(&oidc_settings).await.ok()
217+
} else {
218+
None
220219
};
221220

222-
if oidc.is_none() {
223-
warn!("A user tried to login with OIDC, but OIDC is not configured.");
224-
return Err(ApiError::BadRequest("OIDC not configured".to_string()))
225-
} else {
226-
info!("OIDC is active.");
221+
match new_oidc {
222+
Some(val) => {
223+
info!("OIDC is active.");
224+
*oidc_option = Some(val);
225+
}
226+
None => {
227+
warn!("A user tried to login with OIDC, but OIDC is not configured.");
228+
return Err(ApiError::BadRequest("OIDC not configured".to_string()));
229+
}
227230
}
228231
}
229232

0 commit comments

Comments
 (0)