How can I revoke tokens created through Cognito oauth/token url?

2

We have an application implemented on api-gateway and lambda, the authentication is carried by tokens generated on Cognito, Cognito has the Client credentials OAuth Flow with custom scopes. We are using the oauth/token url to generate access tokens, we tried to create refresh tokens, but the oauth/authorize isn't working, because the Client credential flow restrict the Authorization code grant.

On the middle of the process we need these tokens to be revoked, but the oauth/revoke needs the refresh token that we can't generate because of the chosen flow, How can we can revoke those tokens?

1개 답변
1

Hi,

Currently it is not possible to revoke an access token that is issued using client-credentials flow.

In a token-based authentication system like Cognito, tokens are considered valid as long as they have valid signature and they haven't expired. When these tokens are passed for authorization to back-end (like API Gateway), tokens are validated remotely by verifying its signature and validity, this remote verification doesn't involve any calls to the issuer of the token (cognito). Revoking a token on the authentication server will not invalidate the already issued token and back-end systems that verify this token remotely will continue to accept it.

In your case, if you want to deny access to a token before it is expired, you will need to maintain a deny-list table in DynamoDB for example and if you want to deny access to the token you store its unique identifier (jti claim) in this table and check this table during authorization to make sure that token hasn't been denied access.

AWS
전문가
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인