Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include updates to properties from Google Auth lib #249

Merged
merged 3 commits into from Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions google_auth_oauthlib/helpers.py
Expand Up @@ -133,6 +133,8 @@ def credentials_from_session(session, client_config=None):
token_url=client_config.get("token_uri"),
client_id=client_config.get("client_id"),
client_secret=client_config.get("client_secret"),
token_info_url=client_config.get("token_info_url"),
ScruffyProdigy marked this conversation as resolved.
Show resolved Hide resolved
scopes=session.scope,
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this being added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ends up passing the token_info_url from the login config to the credential class, so we can have an easier time doing introspection later. It also passes the scopes used to the credential class because it is useful for querying

Copy link
Contributor

Choose a reason for hiding this comment

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

can you elaborate on "useful for querying"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a user wants to know whether their credentials have the necessary permissions before trying to use them, they will need to know what scopes were used to create the credentials

Copy link

Choose a reason for hiding this comment

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

The token introspection endpoint is used to retrieve the account identifier for gcloud.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I meant "why is this being added" for the scopes. I get why token_info_url is being added.

)
else:
credentials = google.oauth2.credentials.Credentials(
Expand Down
2 changes: 1 addition & 1 deletion testing/constraints-3.6.txt
Expand Up @@ -5,6 +5,6 @@
#
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
# Then this file should have foo==1.14.0
google-auth==2.13.0
google-auth==2.14.0
Copy link

Choose a reason for hiding this comment

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

update real deps as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. It looks like there are some kokoro dependencies which should be updated (they're currently pinned to version 2.11.0), but it looks like this is best updated through some automated process, as other dependencies will need to be updated as well with hash numbers

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you are referring to https://github.com/googleapis/google-auth-library-python-oauthlib/blob/main/.kokoro/requirements.txt#L165?

@parthea do you know what is this for and if the google-auth version should be updated here manually?

Copy link
Contributor

@parthea parthea Nov 2, 2022

Choose a reason for hiding this comment

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

testing/constraints-3.6.txt should be testing the minimum versions of dependencies as it says at the top of the file. This is correct. The version in testing/constraints-3.6.txt should be google-auth==2.14.0.

The version of google-auth in .kokoro/requirements.txt is used for the release/docs publication and is not related to presubmits/testing. It will be updated automatically as we update dependencies for the release/docs infrastructure.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

requests-oauthlib==0.7.0
click==6.0.0
2 changes: 1 addition & 1 deletion testing/constraints-3.7.txt
Expand Up @@ -5,6 +5,6 @@
#
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
# Then this file should have foo==1.14.0
google-auth==2.13.0
google-auth==2.14.0
requests-oauthlib==0.7.0
click==6.0.0
8 changes: 8 additions & 0 deletions tests/unit/test_helpers.py
Expand Up @@ -95,6 +95,7 @@ def test_credentials_from_session(session):
assert credentials._client_id == CLIENT_SECRETS_INFO["web"]["client_id"]
assert credentials._client_secret == CLIENT_SECRETS_INFO["web"]["client_secret"]
assert credentials._token_uri == CLIENT_SECRETS_INFO["web"]["token_uri"]
assert credentials.scopes == session.scope


def test_credentials_from_session_3pi(session):
Expand All @@ -107,6 +108,9 @@ def test_credentials_from_session_3pi(session):

client_secrets_info = CLIENT_SECRETS_INFO["web"].copy()
client_secrets_info["3pi"] = True
client_secrets_info[
"token_info_url"
] = "https://accounts.google.com/o/oauth2/introspect"
credentials = helpers.credentials_from_session(session, client_secrets_info)

assert isinstance(credentials, external_account_authorized_user.Credentials)
Expand All @@ -116,6 +120,10 @@ def test_credentials_from_session_3pi(session):
assert credentials._client_id == CLIENT_SECRETS_INFO["web"]["client_id"]
assert credentials._client_secret == CLIENT_SECRETS_INFO["web"]["client_secret"]
assert credentials._token_url == CLIENT_SECRETS_INFO["web"]["token_uri"]
assert (
credentials._token_info_url == "https://accounts.google.com/o/oauth2/introspect"
)
assert credentials.scopes == session.scope


def test_bad_credentials(session):
Expand Down