Skip to content

credentials: allow audience to be configured (#8421) #8442

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

Merged
merged 1 commit into from
Jul 14, 2025

Conversation

chrisstaite-menlo
Copy link
Contributor

@chrisstaite-menlo chrisstaite-menlo commented Jul 10, 2025

Fixes: #8421
There are competing specifications around whether a method should be included in a JWT audience or not. For example #4713 specifically excluded the method referencing https://google.aip.dev/auth/4111 whereas GCE IAP requires the full URI https://cloud.google.com/iap/docs/authentication-howto.

In order to facilitate both methods, we introduce a new environment variable, namely GRPC_AUDIENCE_IS_FULL_PATH, to allow the method stripping to be disabled. This defaults to the existing behaviour of stripping the method, but can be set to avoid this.

RELEASE NOTES:

  • credentials: Add support to disable gRPC method name stripping for JWT audience calculation when the environment variable GRPC_AUDIENCE_IS_FULL_PATH is set to true.

Copy link

linux-foundation-easycla bot commented Jul 10, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: chrisstaite-menlo / name: Chris Staite (97573c5)

@chrisstaite-menlo chrisstaite-menlo force-pushed the feature/audience_full_path branch 2 times, most recently from 7361fa2 to 4d729c6 Compare July 10, 2025 08:54
Copy link

codecov bot commented Jul 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.31%. Comparing base (af2600d) to head (97573c5).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8442      +/-   ##
==========================================
+ Coverage   82.27%   82.31%   +0.04%     
==========================================
  Files         414      414              
  Lines       40422    40425       +3     
==========================================
+ Hits        33257    33277      +20     
+ Misses       5799     5780      -19     
- Partials     1366     1368       +2     
Files with missing lines Coverage Δ
internal/envconfig/envconfig.go 100.00% <ø> (ø)
internal/transport/http2_client.go 92.14% <100.00%> (+0.01%) ⬆️

... and 18 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chrisstaite-menlo chrisstaite-menlo force-pushed the feature/audience_full_path branch from 4d729c6 to bb16425 Compare July 10, 2025 09:43
@eshitachandwani eshitachandwani self-assigned this Jul 11, 2025
func (a *audienceTestCreds) RequireTransportSecurity() bool { return false }

func (s) TestGRPCMethodInAudienceWhenEnvironmentSet(t *testing.T) {
oldAudienceIsFullPath := envconfig.AudienceIsFullPath
Copy link
Member

Choose a reason for hiding this comment

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

This can be changed to use the testutil function to set and unset the environment config.
testutils.SetEnvConfig(t, &envconfig.AudienceIsFullPath, true)
This will set to true and reset to original value in the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice :)

@eshitachandwani
Copy link
Member

Please add release notes.

@eshitachandwani eshitachandwani removed the request for review from gtcooke94 July 14, 2025 07:25
@eshitachandwani eshitachandwani added Type: Feature New features or improvements in behavior Type: Security A bug or other problem affecting security Area: Auth Includes regular credentials API and implementation. Also includes advancedtls, authz, rbac etc. labels Jul 14, 2025
@eshitachandwani eshitachandwani added this to the 1.75 Release milestone Jul 14, 2025
@chrisstaite-menlo chrisstaite-menlo force-pushed the feature/audience_full_path branch from bb16425 to 60f17dd Compare July 14, 2025 08:22
@chrisstaite-menlo
Copy link
Contributor Author

chrisstaite-menlo commented Jul 14, 2025

@eshitachandwani I'm sorry, I'm not sure what you mean by release notes, I don't see any in the repository. I have updated the documentation around the environment variable however.

Oh, I think I see... it should be set in the PR description.

I'm confused, I edited the PR description and the validation is still failing. Are you able to help me figure out where I've gone wrong please?

Final edit: figured it out, I had a space before the *, reading the RegExp helped.

@chrisstaite-menlo chrisstaite-menlo force-pushed the feature/audience_full_path branch 2 times, most recently from 764e4c5 to 4257d73 Compare July 14, 2025 08:29
@eshitachandwani
Copy link
Member

LGTM , adding @gtcooke94 to review.

Copy link
Contributor

@gtcooke94 gtcooke94 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 the PR! Just a few small things

@chrisstaite-menlo chrisstaite-menlo force-pushed the feature/audience_full_path branch from 4257d73 to e75172f Compare July 14, 2025 15:32
There are competing specifications around whether a method should be included in a JWT audience or not.  For example grpc#4713 specifically excluded the method referencing https://google.aip.dev/auth/4111 whereas GCE IAP requires the full URI https://cloud.google.com/iap/docs/authentication-howto.

In order to facilitate both methods, we introduce a new environment variable, namely GRPC_AUDIENCE_IS_FULL_PATH, to allow the method stripping to be disabled.  This defaults to the existing behaviour of stripping the method, but can be set to avoid this.
Copy link
Contributor

@gtcooke94 gtcooke94 left a comment

Choose a reason for hiding this comment

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

LGTM - by the way, the commits will automatically be squashed into 1 when the PR is merged, so you don't need to worry about squashing and force-pushing a single commit each update

Thanks for the PR!

@gtcooke94 gtcooke94 merged commit 7208cdc into grpc:master Jul 14, 2025
15 checks passed
@chrisstaite-menlo
Copy link
Contributor Author

Thanks, a lot of those were to force a re-build because the arm64 tests seem super flaky.

@chrisstaite-menlo chrisstaite-menlo deleted the feature/audience_full_path branch July 14, 2025 19:04
@eshitachandwani
Copy link
Member

Reverting this PR to allow for broader cross-language discussion prior to making a decision on incorporating this feature.

@chrisstaite-menlo
Copy link
Contributor Author

That's rather frustrating... this has a severe effect on our ability to use Google Cloud due to its implementation of IAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Auth Includes regular credentials API and implementation. Also includes advancedtls, authz, rbac etc. Type: Feature New features or improvements in behavior Type: Security A bug or other problem affecting security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jwt audience URI vs uir passed to PerRPCCredentials.GetRequestMetadata
3 participants