-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: adds audience validation when validating a jwt #87
Conversation
e56773f
to
ad21f9b
Compare
custom/lib/Auth.php
Outdated
throw new InvalidArgumentException('Missing kid in token'); | ||
$decodedToken = JWT::decode($jwt, $this->jwks); | ||
|
||
$aud = (array) $decodedToken->aud; |
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.
if not array, turn into array
$jwtSegments = explode('.', $jwt); | ||
if (count($jwtSegments) !== 3) { | ||
throw new InvalidArgumentException('Invalid JWT format'); | ||
} |
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.
this is already checked by JWT::decode
here
if (!$header->kid) { | ||
throw new InvalidArgumentException('Missing kid in token'); | ||
if (!in_array($expectedAud, $aud)) { | ||
throw new UnexpectedValueException('JWT audience does not match'); | ||
} |
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.
ced84c7
to
87ce425
Compare
custom/lib/Auth.php
Outdated
$decodedToken = JWT::decode($jwt, $this->jwks); | ||
|
||
$aud = (array) $decodedToken->aud; | ||
$expectedAud = $this->app->getHosted() ? $this->appId : $this->app->getAuthOrigin(); |
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.
Similar to the note in passageidentity/passage-go#89 (comment), the app ID audience claim change is live for all apps in production, so this conditional can be simplified.
c0795cb
to
f722ca7
Compare
What's New?
aud
claim validation when validating a JWTScreenshots (if appropriate):
Type of change
Checklist:
Additional context