Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new client if old client is older than 60 s #1226

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/daemon/auth/providers/openid_connect/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ use std::{
HashMap,
},
ops::Deref,
sync::Arc,
sync::Arc,
time::Instant,
};

use tokio::sync::{RwLock, RwLockReadGuard};
Expand Down Expand Up @@ -151,6 +152,7 @@ pub struct ProviderConnectionProperties {
client: FlexibleClient,
email_scope_supported: bool,
userinfo_endpoint_supported: bool,
time_established: Instant,
logout_mode: LogoutMode,
}

Expand Down Expand Up @@ -179,7 +181,8 @@ impl OpenIDConnectAuthProvider {
async fn initialize_connection_if_needed(&self) -> KrillResult<()> {
let mut conn_guard = self.conn.write().await;

if conn_guard.is_none() {
if conn_guard.is_none() || conn_guard.as_ref().unwrap()
partim marked this conversation as resolved.
Show resolved Hide resolved
.time_established.elapsed().as_secs() >= 60 {
*conn_guard = Some(self.initialize_connection().await?);
}

Expand All @@ -194,10 +197,12 @@ impl OpenIDConnectAuthProvider {
let (email_scope_supported, userinfo_endpoint_supported, logout_mode) =
self.check_provider_capabilities(&meta)?;
let client = self.build_client(meta, &logout_mode)?;
let time_established = Instant::now();
let conn = ProviderConnectionProperties {
client,
email_scope_supported,
userinfo_endpoint_supported,
time_established,
logout_mode,
};
trace!("OpenID Connect: Provider connection initialized");
Expand Down
Loading