8000 expire_jwt_at should not be on the db record but on the jwt. · Issue #18 · stas/otp-jwt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
expire_jwt_at should not be on the db record but on the jwt. #18
Open
@tbem

Description

@tbem

I was exploring how to set up expire_jwt_at and was surprised to see that the expiration is managed at the record level in the database.

This approach has a key drawback: when a user logs in from multiple devices, each new token overwrites the previous expire_jwt_at.

We could define a token lifetime as a constant (e.g., JWT_EXPIRATION_TIME) and encode the expiration (exp) directly inside the token payload at generation time.

This way:
• Expiration is self-contained in the token (no DB lookup required)
• Multiple sessions per user/device can coexist safely
• Token validation uses standard exp verification during decode

Another feature I would like to see is the refresh_token.
There is no refresh_token available. This way we don't offer a way of extend user sessions in a more secure way. We could keep access_token with a low expiration_time and have a refresh_token with expiration_time of 30d for example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0