Skip to content

Support for mutil-value audience claims in JWT token#13490

Merged
kokosing merged 3 commits intotrinodb:masterfrom
rstyp:jwt-aud
Sep 21, 2022
Merged

Support for mutil-value audience claims in JWT token#13490
kokosing merged 3 commits intotrinodb:masterfrom
rstyp:jwt-aud

Conversation

@rstyp
Copy link
Copy Markdown
Contributor

@rstyp rstyp commented Aug 4, 2022

Description

requiredAudience validation fails if aud claim contains multiple audiences in JWT token.

  • Remove jwtParser.requireAudience(config.getRequiredAudience()); to not to validate aud during parseClaimsJws.
  • Add validateAudience method and call it from createIdentity

Is this change a fix, improvement, new feature, refactoring, or other?

a fix

Is this a change to the core query engine, a connector, client library, or the SPI interfaces? (be specific)

JWT Authentication

How would you describe this change to a non-technical end user or system administrator?

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:

# JWT Authentication
* Support for mutil-value audience claims in JWT token. ({issue}`13442 `)

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Aug 4, 2022

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: rstyp.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Aug 4, 2022

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

Copy link
Copy Markdown
Member

@lukasz-walkiewicz lukasz-walkiewicz left a 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.

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

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

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Aug 6, 2022

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

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Aug 11, 2022

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

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Aug 12, 2022

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
Copy link
Copy Markdown
Member

@rstyp Please sign CLA. See instructions from cla-bot.

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Aug 12, 2022

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
Copy link
Copy Markdown
Contributor Author

rstyp commented Aug 22, 2022

@lukasz-walkiewicz CLA is signed now.

Copy link
Copy Markdown
Member

@lukasz-walkiewicz lukasz-walkiewicz left a 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.


private void validateAudience(Claims claims)
{
Object tokenAudience = claims.get(AUDIENCE);
Copy link
Copy Markdown
Member

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

}

@Test
public void testJwtAuthenticatorWithInvalidAudience()
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

@lukasz-walkiewicz lukasz-walkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @rstyp. LGTM 👍
@kokosing could you please take a look as well and merge it?

@rstyp
Copy link
Copy Markdown
Contributor Author

rstyp commented Sep 21, 2022

Thank you @lukasz-walkiewicz

@kokosing
Copy link
Copy Markdown
Member

CI hit: #12818

@kokosing
Copy link
Copy Markdown
Member

CI hit: #13288

@kokosing kokosing merged commit ccfcb9d into trinodb:master Sep 21, 2022
@kokosing
Copy link
Copy Markdown
Member

Merged, thanks

@github-actions github-actions bot added this to the 397 milestone Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants