Skip to content

Commit fd23358

Browse files
committed
Fix multiple OIDC client refresh
1 parent 1667de9 commit fd23358

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/webserver/oidc.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use actix_web::{
1616
};
1717
use anyhow::{anyhow, Context};
1818
use awc::Client;
19+
use base64::write;
1920
use chrono::Utc;
2021
use openidconnect::core::{
2122
CoreAuthDisplay, CoreAuthPrompt, CoreErrorResponseType, CoreGenderClaim, CoreJsonWebKey,
@@ -168,9 +169,11 @@ impl OidcState {
168169
}
169170

170171
async fn refresh(&self, service_request: &ServiceRequest) {
172+
// Obtain a write lock to prevent concurrent OIDC client refreshes.
173+
let mut write_guard = self.client.write().await;
171174
match build_oidc_client_from_appdata(&self.config, service_request).await {
172175
Ok(http_client) => {
173-
*self.client.write().await = ClientWithTime {
176+
*write_guard = ClientWithTime {
174177
client: http_client,
175178
last_update: Instant::now(),
176179
}

0 commit comments

Comments
 (0)