@@ -189,16 +189,17 @@ impl OidcState {
189189 }
190190
191191 /// Gets a reference to the oidc client, potentially generating a new one if needed
192- pub async fn get_client ( & self ) -> RwLockReadGuard < ' _ , ClientWithTime > {
192+ pub async fn get_client ( & self ) -> RwLockReadGuard < ' _ , OidcClient > {
193193 {
194194 let client_lock = self . client . read ( ) . await ;
195195 if client_lock. last_update . elapsed ( ) < OIDC_CLIENT_REFRESH_INTERVAL {
196- return client_lock;
196+ return RwLockReadGuard :: map ( client_lock, | ClientWithTime { client , .. } | client ) ;
197197 }
198198 }
199199 log:: debug!( "OIDC client is older than {OIDC_CLIENT_REFRESH_INTERVAL:?}, refreshing..." ) ;
200200 self . refresh ( ) . await ;
201- self . client . read ( ) . await
201+ let with_time = self . client . read ( ) . await ;
202+ RwLockReadGuard :: map ( with_time, |ClientWithTime { client, .. } | client)
202203 }
203204
204205 /// Validate and decode the claims of an OIDC token, without refreshing the client.
@@ -434,7 +435,7 @@ async fn process_oidc_callback(
434435
435436 let client = oidc_state. get_client ( ) . await ;
436437 log:: debug!( "Processing OIDC callback with params: {params:?}. Requesting token..." ) ;
437- let token_response = exchange_code_for_token ( & client. client , http_client, params) . await ?;
438+ let token_response = exchange_code_for_token ( & client, http_client, params) . await ?;
438439 log:: debug!( "Received token response: {token_response:?}" ) ;
439440
440441 let redirect_target = validate_redirect_url ( state. initial_url ) ;
@@ -698,7 +699,6 @@ async fn build_auth_url(oidc_state: &OidcState) -> AuthUrl {
698699 let scopes = & oidc_state. config . scopes ;
699700 let client_lock = oidc_state. get_client ( ) . await ;
700701 let ( url, csrf_token, _nonce) = client_lock
701- . client
702702 . authorize_url (
703703 CoreAuthenticationFlow :: AuthorizationCode ,
704704 CsrfToken :: new_random,
0 commit comments