nrbnlulu / strawberry-django-auth

Authentication system for django using strawberry

Home Page:https://nrbnlulu.github.io/strawberry-django-auth/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow add extra information to token payload

LinnaViljami opened this issue · comments

Can you explain what you are misssing?

So currently there is no setting to define what type of information we inject into JWT payload section.

So I would want to inhect additional timestamp to the JWT payload, like this:

{
      pk: <user-primary-key=field>,
      strongIdentification: <timestamp-indicates-the-time-user-has-identified-using-bank-account>
}

However, currently our JWT payload handler is assumed to return TokenPayloadType, which consist on the following fields

@strawberry.type(
    description="""
the data that was used to create the token.
"""
)
@inject_fields(
    {
        app_settings.JWT_PAYLOAD_PK,
    }
)
class TokenPayloadType:
    origIat: datetime = strawberry.field(
        description="when the token was created", default_factory=datetime.utcnow
    )
    exp: datetime = strawberry.field(description="when the token will be expired", default=None)

So we can not add an extra field into token payload

I already have implemented custom JWT_PAYLOAD_HANDLER but it does not help me to add extra field to the payload