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

Add ability to add additional information to jwt #1578

Closed
jeremiebourque opened this issue Sep 28, 2022 · 2 comments
Closed

Add ability to add additional information to jwt #1578

jeremiebourque opened this issue Sep 28, 2022 · 2 comments

Comments

@jeremiebourque
Copy link

This project works great at adding non-registered claims but it would be nice to expand the functionality to include ways to modify the jwt because it would make no sense to override the token once again and create a redundant jwt builder process.

If for example this is set:

<?php

namespace App\Claims;

class CustomClaims
{
    public function handle($token, $next)
    {
        $token->addClaim('iss', 'https://localhost:8080');

        return $next($token);
    }

The resulting error will be

    {
    "status": 422,
    "message": "Builder#withClaim() is meant to be used for non-registered claims, check the documentation on how to set claim \"iss\""
}

If I would have downloaded this library for the sole purpose of writing an iss claim, then I'm out-of-luck.
The iss could be set with a $token->issuedBy('http://example.com') method.

Similarly, this library does not allow you to set jwt headers which might be required for openid connect.
For example, a header of

{
...
"kid": 'bar'
}

cannot be set because the $token->withHeader('kid', 'bar') cannot be called.

@driesvints
Copy link
Member

You can already do this by overriding the Token model: https://laravel.com/docs/9.x/passport#overriding-default-models

@abublihi
Copy link

why not the iss claim is set by default?

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