Skip to content

Long-lived tokens #45

@graft

Description

@graft

Janus currently expires tokens after 24 hours. This is required because the token, once issued, cannot be invalidated except by a recycling of secrets (that is, the Janus public key) across all Etna applications.

However, in many instances, mostly long-lived jobs that might take several days to execute, the short-lived token is a nuisance. There are several ways to avoid this nuisance, mostly the /refresh_token and /generate endpoints, which either let you keep a current token alive before it expires, or sign for a new token using a registered public key. Both of these methods involve contacting Janus to serially update the token.

In these instances we'd probably prefer a single, long-lived token that works the same as the regular Janus token, but doesn't require constant refreshing. However, as noted above, we want to be able to invalidate the long-lived token somehow.

To implement, we add a /long_token endpoint that allows the issuing of long-lived tokens. This token is modified in a few ways:

  1. Only one project/role is allowed in its payload.
  2. It has a verify: true bit in its payload.
  3. The expiration is some suitably long period, perhaps 60 days.

The usage is identical; Etna::Auth, in the process of verifying the token (i.e., for each transaction to any Etna app with this token), notes the presence of verify: true and phones Janus at /validate_token, which confirms that the credentials in the token are still valid according to Janus's db. Etna::Auth then rejects or approves on the basis of this received confirmation.

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