@@ -167,6 +167,7 @@ fn get_app_host(config: &AppConfig) -> String {
167167pub struct OidcState {
168168 pub config : Arc < OidcConfig > ,
169169 cached_provider : Arc < RwLock < CachedProvider > > ,
170+ app_config : Arc < AppConfig > ,
170171}
171172
172173impl OidcState {
@@ -181,14 +182,14 @@ impl OidcState {
181182 }
182183
183184 /// Get the current OIDC client, refreshing if stale and possible
184- pub async fn get_client_with_refresh ( & self , app_config : & AppConfig ) -> OidcClient {
185+ pub async fn get_client_with_refresh ( & self ) -> OidcClient {
185186 // Try to refresh if cache is stale and we haven't tried recently
186187 {
187188 let cache = self . cached_provider . read ( ) . await ;
188189 if cache. is_stale ( ) && cache. can_refresh ( ) {
189190 // Release read lock before attempting refresh
190191 drop ( cache) ;
191- if let Err ( e) = self . refresh_provider ( app_config ) . await {
192+ if let Err ( e) = self . refresh_provider ( ) . await {
192193 log:: warn!( "Failed to refresh OIDC provider: {}" , e) ;
193194 }
194195 }
@@ -198,7 +199,7 @@ impl OidcState {
198199 }
199200
200201 /// Refresh provider metadata and client from the OIDC provider
201- async fn refresh_provider ( & self , app_config : & AppConfig ) -> anyhow:: Result < ( ) > {
202+ async fn refresh_provider ( & self ) -> anyhow:: Result < ( ) > {
202203 let mut cache = self . cached_provider . write ( ) . await ;
203204
204205 // Double-check we can refresh (another thread might have just done it)
@@ -213,7 +214,7 @@ impl OidcState {
213214 self . config. issuer_url
214215 ) ;
215216
216- let http_client = make_http_client ( app_config) ?;
217+ let http_client = make_http_client ( & self . app_config ) ?;
217218 let new_metadata =
218219 discover_provider_metadata ( & http_client, self . config . issuer_url . clone ( ) ) . await ?;
219220 let new_client = make_oidc_client ( & self . config , new_metadata. clone ( ) ) ?;
@@ -244,6 +245,7 @@ pub async fn initialize_oidc_state(
244245 let oidc_state = Arc :: new ( OidcState {
245246 config : oidc_cfg,
246247 cached_provider : Arc :: new ( RwLock :: new ( CachedProvider :: new ( client, provider_metadata) ) ) ,
248+ app_config : Arc :: new ( app_config. clone ( ) ) ,
247249 } ) ;
248250
249251 Ok ( Some ( oidc_state) )
0 commit comments