-
-
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
Added support for multiple keys in SignedWith validation #1011
Added support for multiple keys in SignedWith validation #1011
Conversation
@lcobucci Hi, could you please approve the workflows? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the current constraint would weaken the library, I suggest to propose something like a new AtLeastOne
constraint which accepts multiple SignedWith
constraints.
Let's also wrap the array. JWK has the concept of key sets, we can use this as opportunity to introduce the it. |
Using a "JWK Set" does indeed make sense. I see two options:
Option 1 makes more sense to me, since it's still validating against either the Key or KeySet. And since the purpose of the KeySet is to be a list of keys (e.g. key rotation and/or different algorithms) there is no risk of confusion or misuse. |
@rhertogh many apologies for my delay... doing OSS has been a little challenging lately.
I'm not sure if I understood what you mean... Going with option 1 might lead us to abstractions that don't match the real-life possibilities. Perhaps forgetting about the key set for now and having something like the implementation bellow is indeed the most flexible solution for now: use Lcobucci\JWT\Validation\SignedWith as SignedWithInterface;
final class SignedWithOneInSet implements SignedWithInterface
{
/** @var list<SignedWithInterface> */
private readonly array $constraints;
public function __construct(SignedWithInterface ...$constraints)
{
$this->constraints = $constraints;
}
public function assert(object $token): void
{
// (...)
}
} |
In order to support key rotation, this pull request adds the possibility to pass multiple keys to the SignedWith validator to verify against.