Hi @ddpp ,
Thanks for your post! This is a known issue with OpenID Connect, as this is a scenario that the middleware does not handle. When users bookmark the login you need to handle this in your client, typically by re-issuing the authorize request).
One solution (as shared on Github) is to add the following on the authenticating client application where the OpenID Connect middleware is configured:
options.Events.OnRemoteFailure = RemoteAuthFail;
private Task RemoteAuthFail(RemoteFailureContext context) { context.Response.Redirect("/Home/AuthError"); context.HandleResponse(); return Task.CompletedTask; }
Another solution is to catch the exception and check if the request path is /sign-in-oidc (Redirect URI). If it is then redirect to any page that requires authentication, such as the home page. If it is not then you would handle the exception normally.
There are also some alternative solutions and additional details offered in this thread.
Additional resources:
Correlation failed due to bookmarked login page
How to redirect during OnTicketReceived
Redirect in OIDC middleware
-
If the information helped you, please Accept the answer. This will help us and other community members as well.