Skip to content

Data consistency issue when revoking access tokens #645

@gbataille

Description

@gbataille

Opening a new issue from #638 investigation.

Context:

AccessToken expose an API to revoke them: revoke().
I use that when a user does an explicit logout to make sure that the token is invalidated (we can argue whether this is really necessary from a security point of view, but...)

The issue:

revoke() actually just deletes the AccessToken in the db.
Yet, we might still have an associated refresh token.
When trying to use it, it will look for the linked access token to find the scopes associated with the "connection" and will crash when it does not find anything (DoesNotExist AccessToken)

Proposition:

  • do not delete the token from the db, rather just update the "expires" attribute to invalidate it (and let the clear_token() function deal with the deletion when it's safe only)
  • do not delete the token from the db, mark it as revoked (and change the token validation code to recognize a new revoked attribute)
  • delete the RefreshToken at the same time. From my point of view, if the user voluntarily logs out, it's ok to kill his RefreshToken but I'm not sure whether there are other more complex scenari to consider.

Do you agree? which do you prefer? I'm happy to take a crack at it and provide a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions