IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

Front channel logout: empty post_logout_redirect_uri parameter still gets redirected.

Open alennartz opened this issue 7 years ago • 9 comments

Issue

In IdentityServer4 the selection of a post logout redirect uri for front channel logout has a fallback behavior for cases when the logout request does not specify a redirect uri. What it does is check if the client registration has exactly 1 post-logout redirect uri configured and if so, uses that in the validated request object.

see EndSessionRequestValidator.cs

specifically lines 143-156:

var redirectUri = parameters.Get(OidcConstants.EndSessionRequest.PostLogoutRedirectUri);
if (redirectUri.IsPresent())
{
    if (await UriValidator.IsPostLogoutRedirectUriValidAsync(redirectUri, validatedRequest.Client) == false)
    {
        return Invalid("Invalid post logout URI", validatedRequest);
    }

    validatedRequest.PostLogOutUri = redirectUri;
}
else if (validatedRequest.Client.PostLogoutRedirectUris.Count == 1)
{
    validatedRequest.PostLogOutUri = validatedRequest.Client.PostLogoutRedirectUris.First();
}

My preference would be to not redirect the user in this case but the only extension point i have at the moment to change this logic is to re-implement IEndSessionRequestValidator

I was wondering if you would consider changing this behavior in IdentityServer4 directly or barring that, provide an easier way of overriding it.

The specification for front channel logout does seem to imply that not redirecting in this situation is the desireable behavior. See OIDC Session spec or OIDC Front channel logout spec In some cases, the RP will request that the End-User's User Agent to be redirected back to the RP after a logout has been performed. Post-logout redirection is only done when the logout is RP-initiated, in which case the redirection target is the post_logout_redirect_uri query parameter value used by the initiating RP; otherwise it is not done.

However since the wording in the specification does not say that it "MUST NOT" be done I figured I'd open this point for discussion.

Some options i see for ways to change IdentityServer4

  1. Remove the else if portion with the fallback logic completely. (which may break existing implementations when they pull the new version, but brings the implementation closer to the spec.)
  2. Add a more narrowly scoped extension point around this behavior which preserves existing logic. (this could be either a new interface or a slight refactoring of EndSessionRequestValidator, pulling out the fallback redirect uri selection to a virtual method

Let me know what you guys think about this.

Thanks,

alennartz avatar Mar 04 '19 15:03 alennartz

My preference would be to not redirect the user in this case

why?

leastprivilege avatar Mar 08 '19 08:03 leastprivilege

To me it feels like those settings in the Client registration are for validation purposes and that an empty redirect uri in a logout request should be intepreted as "I want you to show some sort of logout confirmation page"

alennartz avatar Mar 11 '19 20:03 alennartz

If you want to show a logout confirmation page, you need to stop sending the `id_token_hint´ parameter. This is what ultimately triggers the confirmation (or rather skips it).

leastprivilege avatar Mar 12 '19 05:03 leastprivilege

The problem for me with not sending id_token_hint is that then i will also get the pre-logout "Are you sure you want to logout"prompt. What i would like is to still be able to bypass that first prompt by providing the id_token_hint but still have a post logout "you have been logged out" page when i choose not to provide post_logout_redirect_uri.

Fundamentally I just feel that fact that the behavior depends on whether or not there is exactly 1 valid post logout redirect uri registered with the client is counter-intuitive, and that people basing themselves off of the OIDC specification to integrate with my STS will not expect it.

alennartz avatar Mar 12 '19 13:03 alennartz

Yea, looking at it again I think I would tend to agree with you. But it's a change in behavior, which I think we'd want to avoid. We can make this change in our next major release. I guess you have a current workaround, so does this sound acceptable?

In short, the change would be to remove the else if (validatedRequest.Client.PostLogoutRedirectUris.Count == 1) clause.

brockallen avatar Jun 30 '19 20:06 brockallen

Yeah, the change would be to remove that special clause. And I agree that a change in behavior should not come unless you have a major version change coming. In the mean time I do indeed have a workaround so I'm not feeling rushed. I'm basically implementing my own end session request validator that wraps an instance of the implementation from IdentityServer4, checks the same condition and clears the State and PostLogOutUri fields on the ValidatedRequest I just don't like how brittle it is since it relies on knowing the implementation details of the wrapped implementation.

alennartz avatar Jul 02 '19 15:07 alennartz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 10 '20 10:01 stale[bot]

PR submitted

brockallen avatar Mar 30 '20 17:03 brockallen

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Nov 26 '20 23:11 github-actions[bot]