Skip to content

feat: blocklist to revoke jwt tokens after logout - #325

Open
MaferMazu wants to merge 4 commits into
release/teak.3from
mfmz/teak-logout-patch
Open

feat: blocklist to revoke jwt tokens after logout#325
MaferMazu wants to merge 4 commits into
release/teak.3from
mfmz/teak-logout-patch

Conversation

@MaferMazu

@MaferMazu MaferMazu commented Jul 28, 2026

Copy link
Copy Markdown

Description

Fixes a security report regarding stateless JWTs remaining valid after user logout. Although the session is invalidated on logout, active JWTs could still be re-used via API calls (e.g., via curl).

To address this, we implemented a custom JWT blocklist mechanism stored in cache to revoke tokens upon logout forcibly.

Changes:

  • Added a JWT blocklist mechanism stored in cache.
  • Updated the authentication decorator to check against the token blocklist.
  • Revoked active user tokens immediately upon logout.

Note: This change is not needed in upstream. There is an ADR about it: https://github.com/openedx/openedx-platform/blob/master/openedx/core/djangoapps/oauth_dispatch/docs/decisions/0009-jwt-in-session-cookie.rst. But for stricter access, we implement this for a specific client.

How to Test

  • Check out this branch (Teak env: tutor<21.0.0).
  • Log in with any test user and copy the JWT token/curl request. (I was copying the curl request that came from the network in the web inspector when I performed this call: http://studio.local.openedx.io:8001/api/contentstore/v2/home/courses?page=1&order=display_name)
  • Log out of the session.
  • Attempt to make an authorized API call using the previous curl request.
  • Expected result: The request should fail (Unauthorized / Invalid Token).

@MaferMazu MaferMazu changed the title feat: blacklist to revoke jwt tokens after logout feat: blocklist to revoke jwt tokens after logout Jul 28, 2026
@MaferMazu MaferMazu self-assigned this Jul 28, 2026


def view_auth_classes(is_user=False, is_authenticated=True):
def view_auth_classes(is_user=False, is_authenticated=True, jwt_authentication_class=BlocklistJwtAuthentication):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

esto esta raro, no te parece? Perfectamente podríamos poner la clase BlocklistJwtAuthentication en la línea 123 directo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants