Skip to content

jwt_authn: Set metadata irrespective of success/failure of JWT Verification#34335

Merged
tyxia merged 1 commit intoenvoyproxy:mainfrom
arulthileeban:main
Jul 15, 2024
Merged

jwt_authn: Set metadata irrespective of success/failure of JWT Verification#34335
tyxia merged 1 commit intoenvoyproxy:mainfrom
arulthileeban:main

Conversation

@arulthileeban
Copy link
Contributor

@arulthileeban arulthileeban commented May 24, 2024

Commit Message: jwt_authn: Set metadata irrespective of success/failure of JWT Verification

Previously, metadata was only set for successful JWT verification, restricting "failed_status_in_metadata". This change removes the condition, allowing both "payload_in_metadata" and "failed_status_in_metadata" to be set as needed.

If this condition was added to restrict setting "payload_in_metadata" only on successful verification, it is unnecessary since "payload_in_metadata" is set only by AuthenticatorImpl:handleGoodJwt().

Risk Level: Low
Testing: Unit tests
Docs Changes: N/A
Release Notes:
Platform Specific Features: N/A
Fixes #32813

…cation

Previously, metadata was only set for successful verification, restricting
"failed_status_in_metadata". This change removes the restriction,
allowing both "payload_in_metadata" and "failed_status_in_metadata"
to be set as needed.

"payload_in_metadata" is set only by AuthenticatorImpl:handleGoodJwt()
which makes this restriction unnecessary earlier.

Signed-off-by: Arul Thileeban Sagayam <arul.thilee@gmail.com>
@arulthileeban arulthileeban requested a review from lizan as a code owner May 24, 2024 04:35
@repokitteh-read-only
Copy link

Hi @arulthileeban, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #34335 was opened by arulthileeban.

see: more, trace.

@adisuissa
Copy link
Contributor

@TAOXUY can you PTAL?

@arulthileeban
Copy link
Contributor Author

@TAOXUY @lizan Could you please take a look? It's a simple fix for an issue that doesn't allow us to use "failed_status_in_metadata" config currently

@alyssawilk alyssawilk assigned kyessenov and unassigned lizan Jun 11, 2024
@tyxia
Copy link
Member

tyxia commented Jun 17, 2024

@kyessenov is OOO and probably won't be able to look at this PR.

@TAOXUY Friendly ping on this as you are the code-owner. I will pass it onto a maintainer review once it is LGTY. Thanks!

@tyxia
Copy link
Member

tyxia commented Jun 22, 2024

/wait-any

@dio @qiwzhang Looks like you touched this feature in #18140 and #4707. The logic here has been successfully verified JWT . wondering what is your opinions on this PR? Thanks in advance!

@arulthileeban
Copy link
Contributor Author

@tyxia Anything that can be done from my end to help get this PR going? It has been stuck for quite a while.

If you are able to add the test I've added, to the upstream code, the setExtractedData callback will fail which is what sets the failed_status_in_metadata. This change is required to make this config work. Also, the "successfully verified JWT" logic was likely there earlier since metadata was only set for successful JWTs through "payload_in_metadata". The failed_status_in_metadata logic came later and this check was probably overlooked when adding that. The current tests also miss this.

The payload_in_metadata is still set only by handleGoodJWT which makes this check redundant.

HandleGoodJWT again is only called when a JWT cache hit happens or if verification succeeds

Copy link
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

Thanks for detailed information @arulthileeban !

This CL LGTM, but I am not familiar with this extension so I think will need the extension owner/other maintainer's approval

@lizan Would you get a chance to look at this PR. Also cced @danieldradware (who added failed_status_to_metadata initially) and @qiwzhang(who reviewed the initial PR)

@arulthileeban
Copy link
Contributor Author

@TAOXUY @lizan Could you PTAL?

@nezdolik
Copy link
Member

nezdolik commented Jul 9, 2024

friendly ping @tyxia (since lizan has left maintainer rotation )

Copy link
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

LGTM

I think it is also good to have a pass from code owner/existing users

@arulthileeban
Copy link
Contributor Author

Would it be possible to get this fix into the upcoming release?

Copy link
Contributor

@kyessenov kyessenov left a comment

Choose a reason for hiding this comment

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

This makes sense to me. I'm not an extension owner, but I've been looking in depth into it recently.

@tyxia tyxia merged commit 5c47c22 into envoyproxy:main Jul 15, 2024
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

Successfully merging this pull request may close these issues.

Cannot access JWT provider failed_status_in_metadata in lua response

8 participants