You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation with iframes and silent signin based on oidc-client-js is causing some timeout issues with third-party IdPs. I've described the cause of this issue in this Stackoverflow question: Blazor WASM - Spending a long time initially in Authorizing component. I'll add my analysis results below.
IMHO, the new solution should allow more freedom for cases like this, where you cannot influence IdP configuration like X-Frame-Options header.
Source of issue
The issue is caused by a timeout in the underlying implementation of the authentication services. I traced down the source, but there's no easy solution to this issue.
If you enable Debug tracing for your WASM client, you should see this log message in the console:
// Clear the previous result of authorization// This will cause the Authorizing state to be displayed until the authorization has been completedisAuthorized=null;currentAuthenticationState=awaitAuthenticationState;isAuthorized=awaitIsAuthorizedAsync(currentAuthenticationState.User);
/// <summary>/// Gets the current authenticated used using JavaScript interop./// </summary>/// <returns>A <see cref="Task{ClaimsPrincipal}"/>that will return the current authenticated user when completes.</returns>protectedinternalvirtualasyncValueTask<ClaimsPrincipal>GetAuthenticatedUser(){awaitEnsureAuthService();varaccount=awaitJsRuntime.InvokeAsync<TAccount>("AuthenticationService.getUser");varuser=awaitAccountClaimsPrincipalFactory.CreateUserAsync(account,Options.UserOptions);returnuser;}
asynctrySilentSignIn(){if(!this._intialSilentSignIn){this._intialSilentSignIn=(async()=>{try{this.debug('Beginning initial silent sign in.');awaitthis._userManager.signinSilent();this.debug('Initial silent sign in succeeded.');}catch(e){if(einstanceofError){this.debug(`Initial silent sign in failed '${e.message}'`);}// It is ok to swallow the exception here.// The user might not be logged in and in that case it// is expected for signinSilent to fail and throw}})();}returnthis._intialSilentSignIn;}
The await this._userManager.signinSilent(); will invoke the oidc-client-jsUserManagersigninSilent and then _signinSilentIframe:
_signinSilentIframe(args={}){leturl=args.redirect_uri||this.settings.silent_redirect_uri||this.settings.redirect_uri;if(!url){Log.error("UserManager.signinSilent: No silent_redirect_uri configured");returnPromise.reject(newError("No silent_redirect_uri configured"));}args.redirect_uri=url;args.prompt=args.prompt||"none";returnthis._signin(args,this._iframeNavigator,{startUrl: url,silentRequestTimeout: args.silentRequestTimeout||this.settings.silentRequestTimeout}).then(user=>{if(user){if(user.profile&&user.profile.sub){Log.info("UserManager.signinSilent: successful, signed in sub: ",user.profile.sub);}else{Log.info("UserManager.signinSilent: no sub");}}returnuser;});}
Finally, this will end up at IFrameWindow.js, which has a timeout of 10000 ms configured:
Original posted by @Herdo:
#40764 (comment)
The current implementation with iframes and silent signin based on oidc-client-js is causing some timeout issues with third-party IdPs. I've described the cause of this issue in this Stackoverflow question: Blazor WASM - Spending a long time initially in Authorizing component. I'll add my analysis results below.
IMHO, the new solution should allow more freedom for cases like this, where you cannot influence IdP configuration like
X-Frame-Options
header.Source of issue
The issue is caused by a timeout in the underlying implementation of the authentication services. I traced down the source, but there's no easy solution to this issue.
If you enable Debug tracing for your WASM client, you should see this log message in the console:
For me - using Keycloak (instead of Auth0), and Discord as IdP behind Keycloak - the Discord login cannot be framed in the hidden iframe:
Of course this policy can be modified to include
discord.com
, but Discord denies being embedded that way withX-Frame-Options
header.What's happening
AuthorizeViewCore
is being rendered, enteringOnParametersSetAsync
:AuthenticationState
is initialized byRemoteAuthenticationService.GetAuthenticationStateAsync
:GetAuthenticatedUser
:AuthenticationService.getUser
will invoketrySilentSignIn
:await this._userManager.signinSilent();
will invoke the oidc-client-js UserManagersigninSilent
and then_signinSilentIframe
:IFrameWindow.js
, which has a timeout of 10000 ms configured:The text was updated successfully, but these errors were encountered: