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

JWT generator: wrong header key "type" #728

Closed
7 tasks done
tricki opened this issue Sep 20, 2023 · 1 comment · Fixed by #729
Closed
7 tasks done

JWT generator: wrong header key "type" #728

tricki opened this issue Sep 20, 2023 · 1 comment · Fixed by #729

Comments

@tricki
Copy link

tricki commented Sep 20, 2023

Checklist

SDK Version

8.7

PHP Version

PHP 8.1

Description

I'm trying to use \Auth0\SDK\Token\Generator to generate a JWT (to return to an Action in Auth0) but kept getting this error:

Error: The session token is invalid: Unexpected token payload type

I solved it by manually adding "typ": "JWT" to the header. The Generator class instead adds a "type": "JWT" to the header. I suspect that should be changed to "typ".

Note: I'm using Auth0-PHP in a Laravel app through auth0/login, but am using Generator directly.

How can we reproduce this issue?

$token = \Auth0\SDK\Token\Generator::create(
    signingKey: 'MY_SECRET',
    algorithm: Token::ALGO_HS256,
    claims: [
        // ...
    ],
    headers: ['typ' => 'JWT'], // this line makes the token valid
);
@evansims evansims linked a pull request Sep 20, 2023 that will close this issue
2 tasks
@evansims
Copy link
Member

Good catch; thanks for reporting this! I've created a PR fixing the issue. I'll merge and release the fix once our team has an opportunity to review the changes.

github-merge-queue bot pushed a commit that referenced this issue Sep 21, 2023
### Changes

This PR fixes a typo in the JSON web token generator class.

### References

Closes #728

### Contributor Checklist

- [x] I agree to adhere to the [Auth0 General Contribution
Guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md).
- [x] I agree to uphold the [Auth0 Code of
Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).
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

Successfully merging a pull request may close this issue.

2 participants