IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

Best practice for token revocation (web clients)

Open d-bitz opened this issue 10 years ago • 7 comments

Problem

I am using the oidc-client in my web application to communicate with IdSvr4. I can login successfully and obtain the user profile and access token.

I am encountering a 400 error when calling Oidc.UserManager.signoutRedirect(): screenshot_28

The post is failing because the server is expecting a client secret: screenshot_29

Question

Storing a secret in a web client doesn't make sense, and although setting RequireClientSecret = false in the Client definition on the server solves the problem this seems like a security vulnerability... but I am not sure.

What is the "proper" way to configure the signout?

d-bitz avatar Oct 14 '16 18:10 d-bitz

Yes, it sounds strange, but if the grant type is configured properly (implicit in this case) then the client will not be allowed to access the token endpoint (which is the other place the RequireClientSecret=false would be applicable).

brockallen avatar Oct 15 '16 14:10 brockallen

We can review to either cleanup the names, and/or ensure there's no vulnerable configuration.

brockallen avatar Oct 15 '16 14:10 brockallen

The grant type is set to Implicit (see below for Client definition). What I am confused about is why the javascript oidc-client checks to see if the current access token needs to be revoked. Should the server not handle revoking any active tokens when a signout occurs ?

Setting RequireClientSecret to false seems dangerous because it exposes the revocation endpoint to anybody.

Maybe I should post this in the oidc-client repo... ?

new Client
{
    ClientName = "Test Website",
    ClientId = "testwebclient",
    AccessTokenType = AccessTokenType.Reference,

    AllowedGrantTypes = GrantTypes.Implicit,
    AllowAccessTokensViaBrowser = true,

    // TODO: without RequireClientSecret = false 
    // Oidc.UserManager.signoutRedirect() throws an 
    // error when logging out (400 because no secret 
    //  is passed).  Is this a security vulnerability?
    RequireClientSecret = false,

    RedirectUris = new List<string>
    {
        "https://localhost:44335",
        "https://localhost:44335/silent_renew.html",
    },
    PostLogoutRedirectUris = new List<string>
    {
        "https://localhost:44335"
    },

    AllowedScopes = new List<string>
    {
         StandardScopes.OpenId.Name,
         StandardScopes.Profile.Name,
         "webapi"
    }
}

d-bitz avatar Oct 17 '16 12:10 d-bitz

Should the server not handle revoking any active tokens when a signout occurs ?

It does not automatically, no.

Setting RequireClientSecret to false seems dangerous because it exposes the revocation endpoint to anybody.

Only if they have a valid access token for that client, which should only be your JS client.

Maybe I should post this in the oidc-client repo

Perhaps there should be a flag in the UserManagerSettings to not use the revocation endpoint automatically. But... if you're signing out, and it's a reference token... then revoking it seems like a good idea to me.

Don't forget that IdSvr4 is still a work in progress. For this workflow we might relax that configuration setting. If we can infer this scenario securely, then I'd like to make it work.

brockallen avatar Oct 17 '16 12:10 brockallen

If we can infer this scenario securely, then I'd like to make it work.

Agreed, this would be ideal.

Don't forget that IdSvr4 is still a work in progress.

Thank you for the great work you guys do! I'm looking forward to this projects continuing development.

d-bitz avatar Oct 17 '16 13:10 d-bitz

For this workflow we might relax that configuration setting. If we can infer this scenario securely, then I'd like to make it work.

Done: For clients that only have the implicit grant type, we allow using revocation endpoint without credentials.

brockallen avatar Nov 30 '16 15:11 brockallen

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

lock[bot] avatar Jan 15 '20 09:01 lock[bot]