GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: adds JwtCredentials with custom claims by chingor13 · Pull Request #290 · googleapis/google-auth-library-java

This repository was archived by the owner on May 12, 2026. It is now read-only.

Conversation

@chingor13

@chingor13 chingor13 commented Jul 9, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Adds the ability to create custom JWT Credentials (JwtCredentials) with custom claims from a ServiceAccountJwtAccessCredentials instance.

  • ServiceAccountJwtAccessCredentials will continue to provide on-demand credentials where the audience is based on the requested URI
  • Adds JwtCredentials class which can be directly built with a PrivateKey, privateKeyId string, and custom JwtCredentials.Claims. You can also build new JwtCredentials via JwtCredentials#jwtWithClaims(JwtCredentials.Claims) which only overrides the new specified claims fields.
  • Add ServiceAccountJwtAccessCredentials#jwtWithClaims(JwtCredentials.Claims) which will provide a JwtCredentials instance with custom claims
  • Changed the credentials cache to be keyed of the full Claims object rather than just the URI.

Fixes: #30

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 9, 2019
@chingor13
chingor13 requested a review from kolea2 July 9, 2019 17:59
@codecov

codecov Bot commented Jul 9, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@1a16f38). Click here to learn what that means.
The diff coverage is 82.78%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #290   +/-   ##
=========================================
  Coverage          ?   79.07%           
  Complexity        ?      357           
=========================================
  Files             ?       24           
  Lines             ?     1606           
  Branches          ?      168           
=========================================
  Hits              ?     1270           
  Misses            ?      251           
  Partials          ?       85
Impacted Files Coverage Δ Complexity Δ
.../google/auth/oauth2/ServiceAccountCredentials.java 81.21% <0%> (ø) 44 <0> (?)
...tp/java/com/google/auth/oauth2/JwtCredentials.java 84.21% <84.21%> (ø) 13 <13> (?)
...h2_http/java/com/google/auth/oauth2/JwtClaims.java 88.88% <88.88%> (ø) 8 <8> (?)
...uth/oauth2/ServiceAccountJwtAccessCredentials.java 75.52% <96.66%> (ø) 36 <2> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a16f38...7db400e. Read the comment docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chingor13 added 7 commits July 11, 2019 11:19
@chingor13
Implement JwtCredentials class. Switch cache to index by claims
95c85c2
@chingor13
DI clock and lifeSpanSeconds
78ace13
@chingor13
Adding Serializable and adding test
a5a4053
@chingor13
Lock for JwtCredentials
bc572f0
@chingor13
Add tests for verifying access tokens and withClaims
a012bcf
@chingor13
Add tests for withClaims for ServiceAccountJwtAccessCredentials
a5d1007
@chingor13
Fix dependency issues
c6015d6
@chingor13
chingor13 marked this pull request as ready for review July 11, 2019 18:44
@chingor13
chingor13 requested a review from a team July 11, 2019 18:44
@chingor13 chingor13 changed the title WIP: Implement JwtCredentials with custom claims Implement JwtCredentials with custom claims Jul 11, 2019
@chingor13
chingor13 requested a review from theacodes July 12, 2019 16:35
theacodes
theacodes approved these changes Jul 12, 2019
View reviewed changes
Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@chingor13
Add CLOCK_SKEW (5 minutes) for shouldRefresh()
6a23cb8
igorbernstein2
igorbernstein2 reviewed Jul 12, 2019
View reviewed changes

@igorbernstein2 igorbernstein2 left a comment

Copy link
Copy Markdown
Contributor

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.

Why wouldn't you push the cache down as well?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chingor13

chingor13 commented Jul 12, 2019

Copy link
Copy Markdown
Contributor Author

Why wouldn't you push the cache down as well?

The cache in ServiceAccountJwtAccessCredentials is used because the credentials are reactionary to the request URI which is used as the audience (and thus handles many audiences). You hang onto the single instance of the ServiceAccountJwtAccessCredentials for all calls you make.

When you request a JwtCredentials with custom claims, you can hang onto that new Credentials instance which can refresh itself when it expires.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@igorbernstein2

igorbernstein2 commented Jul 12, 2019

Copy link
Copy Markdown
Contributor

The cache has a secondary benefit of async refresh as well

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@igorbernstein2

igorbernstein2 commented Jul 12, 2019

Copy link
Copy Markdown
Contributor

Actually nevermind, I never added that part. Sorry for the noise

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chingor13
Adding some javadocs
7b7b76f
@chingor13 chingor13 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 15, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 15, 2019
chingor13
chingor13 commented Jul 15, 2019
View reviewed changes
Comment thread oauth2_http/java/com/google/auth/oauth2/ServiceAccountJwtAccessCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

chingor13 added 2 commits July 15, 2019 11:00
@chingor13
withClaims -> jwtWithClaims and create JwtProvider interface
34d5fa3
@chingor13
Fix javadoc
142e46f
elharo
elharo reviewed Jul 16, 2019
View reviewed changes

@elharo elharo left a comment

Copy link
Copy Markdown
Contributor

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 justifies a minor version bump to 0.17

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chingor13 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtProvider.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/javatests/com/google/auth/oauth2/JwtCredentialsTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/javatests/com/google/auth/oauth2/JwtCredentialsTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pom.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

@chingor13 chingor13 mentioned this pull request Jul 16, 2019
Defer Credential building in HttpCredentialsAdapter until request time #223
Closed
chingor13 added 2 commits July 16, 2019 09:25
@chingor13
Address some PR review nits
307f1ad
@chingor13
expiry -> expiryInSeconds
bf2e100
@chingor13
Disallow null values in JwtCredentials.Builder
b09c6ad
@chingor13 chingor13 added the semver: minor A new feature was added. No breaking changes. label Jul 16, 2019
kolea2
kolea2 reviewed Jul 16, 2019
View reviewed changes
Comment thread oauth2_http/java/com/google/auth/oauth2/ServiceAccountJwtAccessCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

chingor13 added 2 commits July 17, 2019 13:49
@chingor13
Merge branch 'master' into jwt
0cdd973
@chingor13
Update license header for the added files
4db79b0
@chingor13 chingor13 changed the title Implement JwtCredentials with custom claims feat: adds JwtCredentials with custom claims Jul 26, 2019
@chingor13

chingor13 commented Jul 26, 2019

Copy link
Copy Markdown
Contributor Author

@kolea2, @igorbernstein2, @elharo any other concerns here?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

elharo
elharo reviewed Jul 27, 2019
View reviewed changes
Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@chingor13
Address PR review comments
c97f694
elharo
elharo reviewed Jul 29, 2019
View reviewed changes
Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

chingor13 added 7 commits July 29, 2019 11:45
@chingor13
Remove extra whitespace
f0949e3
@chingor13
Merge branch 'master' into jwt
d2a7fec
@chingor13
Fix lint
cc6ecf4
@chingor13
Refactor JwtCredentials.Claims -> JwtClaims
259de34
@chingor13
Merge branch 'master' into jwt
2b7f6a8
@chingor13
fix formatting
6baa26d
@chingor13
javadocs 'New claims' -> 'new claims'
7db400e
kolea2
kolea2 approved these changes Aug 5, 2019
View reviewed changes
@chingor13
chingor13 merged commit 3f37172 into googleapis:master Aug 5, 2019
@release-please release-please Bot mentioned this pull request Jan 4, 2022
chore(main): release google-auth-library-java 1.0.0 #819
Closed
@release-please release-please Bot mentioned this pull request Aug 11, 2022
chore(main): release 1.11.0 #974
Merged
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

4 more reviewers
@elharo elharo elharo left review comments
@igorbernstein2 igorbernstein2 igorbernstein2 left review comments
@theacodes theacodes theacodes approved these changes
@kolea2 kolea2 kolea2 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement. semver: minor A new feature was added. No breaking changes.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

JWT token + getRequestMetadata(entry point)

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@chingor13 @igorbernstein2 @theacodes @elharo @kolea2 @googlebot @kokoro-team
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.