-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Support for mutil-value audience claims in JWT token #13490
Conversation
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: rstyp.
|
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
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.
Looks like a good start but we need to add tests for this change.
Please take a look at io.trino.server.security.TestResourceSecurity
. There are a few test for JWT authentication.
|
||
public class JwtAuthenticator | ||
extends AbstractBearerAuthenticator | ||
{ | ||
private final JwtParser jwtParser; | ||
private final String principalField; | ||
private final UserMapping userMapping; | ||
private final String requiredAudience; |
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.
Typically we use Optional
for values that can have null.
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.
@lukasz-walkiewicz changed it to Optional
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
@rstyp Please sign CLA. See instructions from cla-bot. |
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
@lukasz-walkiewicz CLA is signed now. |
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.
Sorry for the delay @rstyp. Looks good, just a couple of minor comments.
@@ -71,6 +75,32 @@ protected Optional<Identity> createIdentity(String token) | |||
.build()); | |||
} | |||
|
|||
private void validateAudience(Claims claims) | |||
{ | |||
Object tokenAudience = claims.get(AUDIENCE); |
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.
change order, if requiredAudience
is empty then getting audience from claims is redundant
@@ -538,6 +552,34 @@ public void testJwtWithJwkAuthenticator() | |||
} | |||
} | |||
|
|||
@Test | |||
public void testJwtAuthenticatorWithInvalidAudience() |
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.
I think we're missing a test with empty audience and without http-server.authentication.jwt.required-audience
specified.
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.
Thank you @lukasz-walkiewicz |
CI hit: #12818 |
CI hit: #13288 |
Merged, thanks |
Description
requiredAudience
validation fails ifaud
claim contains multiple audiences in JWT token.jwtParser.requireAudience(config.getRequiredAudience());
to not to validateaud
duringparseClaimsJws
.validateAudience
method and call it fromcreateIdentity
a fix
JWT Authentication
Support for mutil-value audience claims in JWT token
Related issues, pull requests, and links
#13442
Documentation
( *) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
( ) Release notes entries required with the following suggested text: