File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -200,14 +200,16 @@ impl<S> OidcService<S> {
200200 ) -> LocalBoxFuture < Result < ServiceResponse < BoxBody > , Error > > {
201201 let oidc_client = Arc :: clone ( & self . oidc_client ) ;
202202 let http_client = Arc :: clone ( & self . http_client ) ;
203+ let oidc_config = Arc :: clone ( & self . config ) ;
203204
204205 Box :: pin ( async move {
205206 let query_string = request. query_string ( ) ;
206207 match process_oidc_callback ( & oidc_client, & http_client, query_string) . await {
207208 Ok ( response) => Ok ( request. into_response ( response) ) ,
208209 Err ( e) => {
209210 log:: error!( "Failed to process OIDC callback with params {query_string}: {e}" ) ;
210- Ok ( request. into_response ( HttpResponse :: BadRequest ( ) . body ( e. to_string ( ) ) ) )
211+ let auth_url = build_auth_url ( & oidc_client, & oidc_config. scopes ) ;
212+ Ok ( request. into_response ( build_redirect_response ( auth_url) ) )
211213 }
212214 }
213215 } )
@@ -457,3 +459,15 @@ struct OidcCallbackParams {
457459 code : String ,
458460 state : String ,
459461}
462+
463+ fn build_auth_url ( oidc_client : & OidcClient , scopes : & [ Scope ] ) -> String {
464+ let ( auth_url, csrf_token, nonce) = oidc_client
465+ . authorize_url (
466+ CoreAuthenticationFlow :: AuthorizationCode ,
467+ CsrfToken :: new_random,
468+ Nonce :: new_random,
469+ )
470+ . add_scopes ( scopes. iter ( ) . cloned ( ) )
471+ . url ( ) ;
472+ auth_url. to_string ( )
473+ }
You can’t perform that action at this time.
0 commit comments