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: allow scopes for self signed jwt by arithmetic1728 · Pull Request #776 · googleapis/google-auth-library-python

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

Conversation

@arithmetic1728

@arithmetic1728 arithmetic1728 commented Jun 14, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

This doc implements https://google.aip.dev/auth/4111. Internal doc: go/yoshi-self-signed-jwt-phase-2.

The main feature here is now we can use scope claim in self signed JWT.

This PR does the following 2 things:
(1) Add always_use_jwt_access property to service account credentials to allow opt-in for the feature.
(2) If always_use_jwt_access is True, then apply the following logic. If alwaysUseJwtAccess is False, the logic is the same as before; if True, then we can always use self signed jwt with scopes or audience.

if (alwaysUseJwtAccess):
    if (scope):
        // create a self signed JWT with "scope" set to the scope
    else if (audience):
        // create a self signed JWT with "aud" set to the audience
    else if (defaultScope):
        // create a self signed JWT with "scope" set to the defaultScope
else:
    if (scope):
        // call OAuth token endpoint
    else if (audience):
        // create a self signed JWT with audience
    else if (defaultScope):
        // call OAuth token endpoint

This PR has been tested with python-kms, googleapis/python-kms#122

The follow up PR in python microgenerator is: googleapis/gapic-generator-python#920

Sorry, something went wrong.

Uh oh!

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

All reactions
@arithmetic1728
feat: allow scopes for self signed jwt
a4b2125
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Jun 14, 2021
arithmetic1728 and others added 2 commits June 14, 2021 11:31
@arithmetic1728
Update service_account.py
22dee03
@arithmetic1728
add http changes
bb1ed8d
@arithmetic1728 arithmetic1728 mentioned this pull request Jun 15, 2021
feat: enable self signed jwt for grpc googleapis/gapic-generator-python#920
Merged
@arithmetic1728
arithmetic1728 marked this pull request as ready for review June 15, 2021 03:48
@arithmetic1728
arithmetic1728 requested review from a team, bshaffer and busunkim96 June 15, 2021 03:48
tseaver
tseaver reviewed Jun 15, 2021
View reviewed changes
Comment thread google/auth/jwt.py Resolved

Uh oh!

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

busunkim96
busunkim96 reviewed Jun 15, 2021
View reviewed changes
Comment thread google/oauth2/service_account.py
Comment on lines +425 to +428
elif audience:
self._jwt_credentials = jwt.Credentials.from_signing_credentials(
self, audience
)

@busunkim96 busunkim96 Jun 15, 2021 •
edited
Loading

Uh oh!

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

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.

I think the way google-api-core is written it will always pass through an audience. https://github.com/googleapis/python-api-core/blob/155da5e18cc2fdcfa57de6f956b7d078e79cd4b7/google/api_core/grpc_helpers.py#L249-L251 and the elif self._default_scopes case will never be reached.

Is it necessary to distinguish between the "default" audience and a user defined audience? It looks like Cody asked a question about this in the doc as well.

Sorry, something went wrong.

Uh oh!

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

All reactions

@arithmetic1728 arithmetic1728 Jun 16, 2021

Copy link
Copy Markdown
Contributor Author

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 it is fine that self._default_scopes is never reached. We can just leave it here for logic completeness.

We don't need to distinguish a default audience and a user defined audience. If the user doesn't provide the scope but provides the audience, then they are responsible that the audience is correct.

Sorry, something went wrong.

Uh oh!

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

busunkim96 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
arithmetic1728
arithmetic1728 commented Jun 16, 2021
View reviewed changes
Comment thread google/auth/jwt.py Resolved

Uh oh!

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

@arithmetic1728
Update google/auth/jwt.py
1c9a64a
busunkim96
busunkim96 approved these changes Jun 16, 2021
View reviewed changes
@arithmetic1728
arithmetic1728 merged commit 2cfe655 into master Jun 16, 2021
@arithmetic1728
arithmetic1728 deleted the sijun_jwt branch June 16, 2021 22:30
@busunkim96 busunkim96 mentioned this pull request Jun 24, 2021
feat: add always_use_jwt_access googleapis/python-asset#211
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@bshaffer bshaffer Awaiting requested review from bshaffer
2 more reviewers
@tseaver tseaver tseaver left review comments
@busunkim96 busunkim96 busunkim96 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.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

3 participants

@arithmetic1728 @tseaver @busunkim96
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.