-
-
Notifications
You must be signed in to change notification settings - Fork 601
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
How get Claims after encode token #203
Comments
@lpj145 that's a forward compatibility layer. As stated on #6 we plan to support encrypted tokens (which will implement that interface). Since $token = $this->parser->parse($jwt);
if (! $token instanceof Plain) {
// You should have your own exception for that, sure =)
throw new \RuntimeException('The provided token is not valid');
} |
btw don't forget to validate the token properly using the validator 😉 |
yep i'm using:
|
@lpj145 if you're not using the exception, I'd suggest to use this instead (I really need to work on the documentation 😭 ): return $this->validator->validate(
$token,
new ValidAt(new SystemClock()),
new SignedWith($this->signer, $this->key)
); The benefits with that approach are: the validator will stop its process when the first error comes and the constraints will be processed in the order you called the method - so you can leave the "expensive" operations to the end of your validation chain. I'd also suggest to have the list of constraints injected, so it makes it easier for you (we're planning to add it to the return $this->validator->validate($token, ...$this->constraints); |
@lpj145 let me know if your question has been answered and we can close this issue 👍 |
I think this is a good solution, but need tests. in hour i answer to you.
|
I'm try to get claim on middleware.
Using Version 4.0@dev
But
parse
function return Plain, this is a error ?The text was updated successfully, but these errors were encountered: