Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow access tokens to be refreshed to gain new rights #2271

Open
BryanCrotaz opened this issue Feb 7, 2021 · 2 comments
Open

Allow access tokens to be refreshed to gain new rights #2271

BryanCrotaz opened this issue Feb 7, 2021 · 2 comments

Comments

@BryanCrotaz
Copy link
Contributor

BryanCrotaz commented Feb 7, 2021

Access tokens are bearer tokens, so they contain the information regarding what this user is allowed to do.

Scenario:

  1. Administrator increases the rights of the logged in user.
  2. User has to wait until the access token expires (which is invisible to them) to get the new rights

User should be able to refresh their rights, under the hood calling

this.session.refreshToken

Of course some authentication methods don't use bearer tokens, so this would be meaningless in those cases.

Better:

this.session.authenticator.refreshToken

All ember-simple-auth needs to do is to make the authenticator object a public property of the session service.

@hoIIer
Copy link

hoIIer commented Mar 20, 2022

I need to do this as well, is there any activity here? My use case is the exact same as @BryanCrotaz where a user has certain claim data updated and I need a way to get a fresh token.

@hoIIer
Copy link

hoIIer commented Mar 21, 2022

Was able to get it working but would still be nice if refreshToken() were available on the service:

      // refresh the access token.
      const auth = getOwner(this).lookup('authenticator:jwt');
      const { token } = this.session.session.content.authenticated;
      auth.refreshAccessToken(token, 0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants