Skip to content

.Net Core SignOut() RedirectUri not working #28009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TestO2015 opened this issue Nov 20, 2020 · 9 comments
Closed

.Net Core SignOut() RedirectUri not working #28009

TestO2015 opened this issue Nov 20, 2020 · 9 comments
Labels
area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved

Comments

@TestO2015
Copy link

I'm trying to do a SignOut with a redirect uri specified in the AuthenticationProperties. It redirects to the OIDC SignedOutCallbackPath I configured but doesn't make it to the RedirectURI.

    [HttpGet("Logout")]
    public async Task Logout()
    {
        var prop = new AuthenticationProperties()
        {
            RedirectUri = "http://google.com"
        };

        await HttpContext.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, prop);
    }

Setup and info:

  • The app has Cookie and OpenId Connect authentication setup
  • Connects to Oracle IDCS.
  • Both HttpContext.SignOutAsync() and SignOut() have the same result.
  • A login via ChallengeRequest with a RedirectUri on the other hand works.

How does the Redirect URI actually work inside - ex. does it get sent to the Identity Provider and back? Any clues as to why this doesn't work?

@javiercn javiercn added the area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer label Nov 20, 2020
@Tratcher
Copy link
Member

Here's the part where the signout starts. It forwards the RedirectUri via a state property just like Challenge does.

// Get the post redirect URI.
if (string.IsNullOrEmpty(properties.RedirectUri))

And here's where it comes back:

var message = new OpenIdConnectMessage(Request.Query.Select(pair => new KeyValuePair<string, string[]>(pair.Key, pair.Value)));
AuthenticationProperties properties = null;
if (!string.IsNullOrEmpty(message.State))
{
properties = Options.StateDataFormat.Unprotect(message.State);
}

If you trace the request do you see the state field coming back? If you hook into the SignedOutCallbackRedirect event do you see the RedirectUri you set in the Properties?

@Tratcher Tratcher added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Nov 20, 2020
@AndrewTriesToCode
Copy link
Contributor

@Tratcher beat me to it but I'll add that it seems not all open ID connect providers actually call the sign out callback, or if they do its just a static preconfigured URL they'll hit--without the state information passed in. If you don't see the callback getting called that could be why.

OpenID Connect and OAuth sign out isn't as well-defined out as sign in.

@TestO2015
Copy link
Author

TestO2015 commented Nov 22, 2020

@Tratcher The OnRedirectToIdentityProviderForSignOut event does show the .redirectUri property. OnRemoteSignOut does not and OnSignedOutCallbackRedirect isn't called at all.

I can see the state field present when it reaches the signed out callback path:

https://myhost/myapp/signout-oidc?state=CfDJ8FDX1DIGbFhFpGXGafv92zCXFWXuErnnkL5NwfZ2AINAiKEOY4OmXcRtNLzG07hjHXDgQrMq5k-1gaXeG_vWx2_ljys1Qqn9ahV3qOLMH6V_LeETjROjNsCbYUmbDB52JysBVeLwsqawQALjK25-9jVM_sedBCirBATW0ltc1TO6

@AndrewTriesToCode Do you think the fact that OnSignedOutCallbackRedirect isn't hit indicates that Oracle IDCS doesn't call the signed out callback?

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Nov 22, 2020
@Tratcher
Copy link
Member

Do you think the fact that OnSignedOutCallbackRedirect isn't hit indicates that Oracle IDCS doesn't call the signed out callback?

Makes sense. It's interesting it called OnRemoteSignOut instead. That's normally reserved for notifications that a central sign-out was requested by another application.

It might also be a registration issue. You've registered the login callback path ("/signin-oidc") with Oracle, right? What about the signed out callback path "/signout-callback-oidc"?

SignedOutCallbackPath = new PathString("/signout-callback-oidc");
RemoteSignOutPath = new PathString("/signout-oidc");

@Tratcher Tratcher added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Nov 23, 2020
@TestO2015
Copy link
Author

TestO2015 commented Nov 24, 2020

It might also be a registration issue. You've registered the login callback path ("/signin-oidc") with Oracle, right? What about the signed out callback path "/signout-callback-oidc"?

Yes I do have /signin-oidc configured in Oracle under the Post Logout Redirect Uri.

I can see that the post_logout_redirect_uri is not set correctly in the logout API call. It always uses the OIDC SignedOutCallbackPath regardless of what I've configured in the RedirectUri. I tested in Azure AD and it works fine - it uses the RedirectUri and OnSignedOutCallbackRedirect gets called - but I need to use Oracle IDCS.

https://idcs-9ce....identity.oraclecloud.com/oauth2/v1/userlogout?post_logout_redirect_uri=https%3A%2F%2Fmyapp%2Fsignout-callback-oidc&id_token_hint=...

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Nov 24, 2020
@Tratcher
Copy link
Member

I can see that the post_logout_redirect_uri is not set correctly in the logout API call. It always uses the OIDC SignedOutCallbackPath regardless of what I've configured in the RedirectUri.

That's expected. It's supposed to return to "/signout-callback-oidc" and then be redirected locally to your RedirectUri. Make sure "/signout-callback-oidc" is registered as a valid Post Logout Redirect Uri.

@Tratcher Tratcher added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Nov 24, 2020
@TestO2015
Copy link
Author

@Tratcher I was setting the OIDC SignedOutCallbackPath to "/signout-oidc" and apparently that causes the the RedirectUri to not be used. I'm not sure why.

After registering the default "/signout-callback-oidc" value in IDCS instead, it works - I'm good with this.

Thanks for your help.

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Nov 25, 2020
@Tratcher
Copy link
Member

signout-oidc is the value for RemoteSignOutPath which is intended to handle a different flow. Setting them to the same value seems to have caused a conflict.

SignedOutCallbackPath = new PathString("/signout-callback-oidc");
RemoteSignOutPath = new PathString("/signout-oidc");

@Tratcher Tratcher added ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Nov 25, 2020
@ghost ghost added the Status: Resolved label Nov 25, 2020
@ghost
Copy link

ghost commented Nov 26, 2020

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Nov 26, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 26, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved
Projects
None yet
Development

No branches or pull requests

4 participants