Skip to content

A module to handle tokens.

This module is responsible for token responses, signing and decoding. For more control on JWE duration, you can set JWE_SECRET with your own secret.

Functions
  • decrypt_jwe(token) (dict) Decode the token.</>
  • encrypt_jwe(expiry_seconds, **token_attrs) (dict) Sign a paylod and return the signed token.</>
  • token_response(token) (dict) Returns a token response for a given token.</>

Returns a token response for a given token.

Parameters
  • token (str) The token to be used.
Returns (dict)

A dict with the access token.

function

handler.server.auth.auth_handler.encrypt_jwe(expiry_seconds=86400, **token_attrs)

Sign a paylod and return the signed token.

Parameters
  • expiry_seconds (int) Amount of seconds before expire.
  • token_attrs (dict) Attributes to be encrypted with the token.
Returns (dict)

A token with the signed payload.

Decode the token.

Parameters
  • token (str) The token to be decodded.
Returns (dict)

The decoded token if possible to decode, or else an empty dict.