Skip to content

Passport refresh token if stale #478

Open

Description

@fcaps

The website session is longer than the token ttl from hydra, so you can be logged in while your token is outdated.
To combat this we need some automatic check if the token is stale and refresh it if possible.

For axios it could look like:

instance.interceptors.request.use(config => {
    if (token.expired()) {
      token = token.refresh()
    }

    config.headers['Authorization'] = `Bearer ${token.token.access_token}`;
    return config;
  });

open questions:

  • what if we cannot refresh? maybe throw an exception that can trigger client redirect to login?
  • how to make this globally available? maybe some global axiosClient?
  • how to implement this in tiny steps

Activity

  1. self-assigned this
    on Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions