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

The user adds the access_token custom data #883

Closed
sowork opened this issue Nov 16, 2018 · 7 comments
Closed

The user adds the access_token custom data #883

sowork opened this issue Nov 16, 2018 · 7 comments

Comments

@sowork
Copy link

sowork commented Nov 16, 2018

I want to be able to add extra values when generating access_token, and get access_token by parsing it through some method, such as when a multi-table user logs in, I need to add a token to access_token, and I can get it when the client sends it.thank you

@driesvints
Copy link
Member

You can overwrite the migrations and a add more columns if you like. The Token is a model which is returned on the user after authentication or when being created you can use the AccessTokenCreated to retrieve it and update it as you see fit.

Adding extra columns natively in this package is something that has been requested a lot before but will not happen anytime soon, sorry.

@sowork
Copy link
Author

sowork commented Nov 19, 2018

What I might describe as problematic is that I want to get other values through JWT without going through the database.

For example, the rule + custom data generated for JWT might provide a method for me to add?

@sowork
Copy link
Author

sowork commented Nov 19, 2018

trait AccessTokenTrait
{
    public function convertToJWT(CryptKey $privateKey)
    {
        return (new Builder())
            ->setAudience($this->getClient()->getIdentifier())
            ->setId($this->getIdentifier(), true)
            ->setIssuedAt(time())
            ->setNotBefore(time())
            ->setExpiration($this->getExpiryDateTime()->getTimestamp())
            ->setSubject($this->getUserIdentifier())
            ->set('scopes', $this->getScopes())
            ->sign(new Sha256(), new Key($privateKey->getKeyPath(), $privateKey->getPassPhrase()))
            ->getToken();
      }
}

e.g
access_token = rule(original data)
now : access_token = rule(original data + custom data)

@driesvints
Copy link
Member

@sowork ah, I think what you're looking for in this case is #94 ?

@fredsal
Copy link

fredsal commented Apr 20, 2022

@driesvints
Copy link
Member

@fredsal can you please not spam multiple issues?

@fredsal
Copy link

fredsal commented Apr 26, 2022

Not spam, just tagging related issues with the PR for easy access

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

No branches or pull requests

3 participants