Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
41599ae
refactor: split 'with_quota_project' into separate base class (#561)
busunkim96 Sep 2, 2020
d32f7df
fix: dummy commit to trigger a auto release (#597)
arithmetic1728 Sep 3, 2020
892dc37
chore: release 1.21.1 (#599)
release-please[bot] Sep 3, 2020
694d83f
fix: migrate signBlob to iamcredentials.googleapis.com (#600)
busunkim96 Sep 8, 2020
b921a0a
chore: release 1.21.2 (#601)
release-please[bot] Sep 16, 2020
d0e0aba
fix: fix expiry for `to_json()` (#589)
wescpy Sep 17, 2020
da3526f
chore: add default CODEOWNERS (#609)
busunkim96 Sep 22, 2020
cc91e75
chore: release 1.21.3 (#607)
release-please[bot] Sep 23, 2020
7e15258
feat: add asyncio based auth flow (#612)
crwilcox Sep 28, 2020
ee5617c
chore: release 1.22.0 (#615)
release-please[bot] Sep 28, 2020
a924011
fix: move aiohttp to extra as it is currently internal surface (#619)
crwilcox Oct 5, 2020
7f957ba
chore: release 1.22.1 (#620)
release-please[bot] Oct 5, 2020
6407258
fix: remove checks for ancient versions of Cryptography (#596)
akx Oct 8, 2020
3b3172e
tests: fix unit tests on python 3.6 / 3.7 (#630)
tseaver Oct 22, 2020
5906c85
Change metadata service helper to work with any query parameters (#588)
davidwtbuxton Oct 23, 2020
05f9524
fix: pin 'aoihttp < 3.7.0dev' (#634)
tseaver Oct 27, 2020
755e702
chore: add infrastructure to support `docs-presubmit` build (via synt…
yoshi-automation Oct 28, 2020
9c4200d
Update example in oauth2.id_token docs (#624)
matthewhughes934 Oct 28, 2020
d0a47c1
build: use pypi secret from secret manager (#639)
yoshi-automation Oct 29, 2020
0323cf3
feat: Add custom scopes for access tokens from the metadata service (…
davidwtbuxton Oct 29, 2020
b790e65
fix(deps): Revert "fix: pin 'aoihttp < 3.7.0dev' (#634)" (#632) (#640)
davidwtbuxton Oct 29, 2020
bc92abb
chore: release 1.23.0 (#641)
release-please[bot] Oct 29, 2020
3319ea8
docs: fix typo in import (#651)
busunkim96 Dec 7, 2020
2d3b8d1
chore: fix comment about clock_skew (#653)
busunkim96 Dec 8, 2020
6de753d
feat: add Python 3.9 support, drop Python 3.5 support (#655)
tseaver Dec 11, 2020
da922f0
chore: add constraints file (#649)
busunkim96 Dec 11, 2020
ec1b688
chore: fix typo (#647)
dgorelik Dec 11, 2020
fd9b5b1
fix: avoid losing the original '_include_email' parameter in imperson…
pietrodn Dec 11, 2020
647290a
chore: release 1.24.0 (#656)
release-please[bot] Dec 11, 2020
84d4e19
Merge remote-tracking branch 'upstream/byoid'
bojeil-google Jan 7, 2021
ae36584
fix: add AWS URL basic validation
bojeil-google Jan 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@

[1]: https://pypi.org/project/google-auth/#history

## [1.24.0](https://www.github.com/googleapis/google-auth-library-python/compare/v1.23.0...v1.24.0) (2020-12-11)


### Features

* add Python 3.9 support, drop Python 3.5 support ([#655](https://www.github.com/googleapis/google-auth-library-python/issues/655)) ([6de753d](https://www.github.com/googleapis/google-auth-library-python/commit/6de753d585254c813b3e6cbde27bf5466261ba10)), closes [#654](https://www.github.com/googleapis/google-auth-library-python/issues/654)


### Bug Fixes

* avoid losing the original '_include_email' parameter in impersonated credentials ([#626](https://www.github.com/googleapis/google-auth-library-python/issues/626)) ([fd9b5b1](https://www.github.com/googleapis/google-auth-library-python/commit/fd9b5b10c80950784bd37ee56e32c505acb5078d))


### Documentation

* fix typo in import ([#651](https://www.github.com/googleapis/google-auth-library-python/issues/651)) ([3319ea8](https://www.github.com/googleapis/google-auth-library-python/commit/3319ea8ae876c73a94f51237b3bbb3f5df2aef89)), closes [#650](https://www.github.com/googleapis/google-auth-library-python/issues/650)

## [1.23.0](https://www.github.com/googleapis/google-auth-library-python/compare/v1.22.1...v1.23.0) (2020-10-29)


Expand Down
4 changes: 4 additions & 0 deletions google/auth/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def get_request_options(
additional_headers = additional_headers or {}

uri = urllib.parse.urlparse(url)
# Validate provided URL.
if not uri.hostname or uri.scheme != "https":
raise ValueError("Invalid AWS service URL")

header_map = _generate_authentication_header_map(
host=uri.hostname,
canonical_uri=os.path.normpath(uri.path or "/"),
Expand Down
4 changes: 2 additions & 2 deletions google/auth/compute_engine/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

"""Google Compute Engine credentials.

This module provides authentication for application running on Google Compute
Engine using the Compute Engine metadata server.
This module provides authentication for an application running on Google
Compute Engine using the Compute Engine metadata server.

"""

Expand Down
2 changes: 1 addition & 1 deletion google/auth/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def expired(self):
if not self.expiry:
return False

# Remove 5 minutes from expiry to err on the side of reporting
# Remove 10 seconds from expiry to err on the side of reporting
# expiration early so that we avoid the 401-refresh-retry loop.
skewed_expiry = self.expiry - _helpers.CLOCK_SKEW
return _helpers.utcnow() >= skewed_expiry
Expand Down
4 changes: 3 additions & 1 deletion google/auth/impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Credentials(credentials.CredentialsWithQuotaProject, credentials.Signing):
Initialize a source credential which does not have access to
list bucket::

from google.oauth2 import service_acccount
from google.oauth2 import service_account

target_scopes = [
'https://www.googleapis.com/auth/devstorage.read_only']
Expand Down Expand Up @@ -353,13 +353,15 @@ def from_credentials(self, target_credentials, target_audience=None):
return self.__class__(
target_credentials=self._target_credentials,
target_audience=target_audience,
include_email=self._include_email,
quota_project_id=self._quota_project_id,
)

def with_target_audience(self, target_audience):
return self.__class__(
target_credentials=self._target_credentials,
target_audience=target_audience,
include_email=self._include_email,
quota_project_id=self._quota_project_id,
)

Expand Down
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def blacken(session):
session.run("black", *BLACK_PATHS)


@nox.session(python=["3.6", "3.7", "3.8"])
@nox.session(python=["3.6", "3.7", "3.8", "3.9"])
def unit(session):
session.install(*TEST_DEPENDENCIES)
session.install(*(ASYNC_DEPENDENCIES))
Expand All @@ -88,7 +88,7 @@ def unit(session):
)


@nox.session(python=["2.7", "3.5"])
@nox.session(python=["2.7"])
def unit_prev_versions(session):
session.install(*TEST_DEPENDENCIES)
session.install(".")
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"pyasn1-modules>=0.2.1",
# rsa==4.5 is the last version to support 2.7
# https://github.com/sybrenstuvel/python-rsa/issues/152#issuecomment-643470233
'rsa<4.6; python_version < "3.5"',
'rsa>=3.1.4,<5; python_version >= "3.5"',
'rsa<4.6; python_version < "3.6"',
'rsa>=3.1.4,<5; python_version >= "3.6"',
"setuptools>=40.3.0",
"six>=1.9.0",
)
Expand All @@ -34,7 +34,7 @@
with io.open("README.rst", "r") as fh:
long_description = fh.read()

version = "1.23.0"
version = "1.24.0"

setup(
name="google-auth",
Expand All @@ -48,17 +48,17 @@
namespace_packages=("google",),
install_requires=DEPENDENCIES,
extras_require=extras,
python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*",
license="Apache 2.0",
keywords="google auth oauth client",
classifiers=[
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
Expand Down
8 changes: 0 additions & 8 deletions system_tests/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,7 @@ def configure_cloud_sdk(session, application_default_credentials, project=False)

# Test sesssions

<<<<<<< HEAD
TEST_DEPENDENCIES_ASYNC = ["aiohttp", "pytest-asyncio", "nest-asyncio"]
=======
TEST_DEPENDENCIES_ASYNC = ["aiohttp < 3.7.0dev", "pytest-asyncio", "nest-asyncio"]
>>>>>>> upstream/byoid
TEST_DEPENDENCIES_SYNC = ["pytest", "requests"]
PYTHON_VERSIONS_ASYNC = ["3.7"]
PYTHON_VERSIONS_SYNC = ["2.7", "3.7"]
Expand Down Expand Up @@ -319,11 +315,7 @@ def default_explicit_service_account_async(session):
session.env[EXPECT_PROJECT_ENV] = "1"
session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
session.install(LIBRARY_DIR)
<<<<<<< HEAD
session.run("pytest", "system_tests_async/test_default.py",
=======
session.run("pytest", "system_tests_async/test_default.py",
>>>>>>> upstream/byoid
"system_tests_async/test_id_token.py")


Expand Down
Empty file added testing/constraints-3.10.txt
Empty file.
Empty file added testing/constraints-3.11.txt
Empty file.
14 changes: 14 additions & 0 deletions testing/constraints-3.6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This constraints file is used to check that lower bounds
# are correct in setup.py
# List *all* library dependencies and extras in this file.
# Pin the version to the lower bound.
#
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
# Then this file should have foo==1.14.0
cachetools==2.0.0
pyasn1-modules==0.2.1
setuptools==40.3.0
six==1.9.0
rsa==4.6
rsa==3.1.4
aiohttp==3.6.2
Empty file added testing/constraints-3.7.txt
Empty file.
Empty file added testing/constraints-3.8.txt
Empty file.
Empty file added testing/constraints-3.9.txt
Empty file.
45 changes: 45 additions & 0 deletions tests/test_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,51 @@ def test_get_request_options(

assert actual_signed_request == signed_request

def test_get_request_options_with_missing_scheme_url(self):
request_signer = aws.RequestSigner("us-east-2")

with pytest.raises(ValueError) as excinfo:
request_signer.get_request_options(
{
"access_key_id": ACCESS_KEY_ID,
"secret_access_key": SECRET_ACCESS_KEY,
},
"invalid",
"POST",
)

assert excinfo.match(r"Invalid AWS service URL")

def test_get_request_options_with_invalid_scheme_url(self):
request_signer = aws.RequestSigner("us-east-2")

with pytest.raises(ValueError) as excinfo:
request_signer.get_request_options(
{
"access_key_id": ACCESS_KEY_ID,
"secret_access_key": SECRET_ACCESS_KEY,
},
"http://invalid",
"POST",
)

assert excinfo.match(r"Invalid AWS service URL")

def test_get_request_options_with_missing_hostname_url(self):
request_signer = aws.RequestSigner("us-east-2")

with pytest.raises(ValueError) as excinfo:
request_signer.get_request_options(
{
"access_key_id": ACCESS_KEY_ID,
"secret_access_key": SECRET_ACCESS_KEY,
},
"https://",
"POST",
)

assert excinfo.match(r"Invalid AWS service URL")


class TestCredentials(object):
AWS_REGION = "us-east-2"
Expand Down
8 changes: 6 additions & 2 deletions tests/test_impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,13 @@ def test_id_token_from_credential(
assert not credentials.expired

id_creds = impersonated_credentials.IDTokenCredentials(
credentials, target_audience=target_audience
credentials, target_audience=target_audience, include_email=True
)
id_creds = id_creds.from_credentials(target_credentials=credentials)
id_creds.refresh(request)

assert id_creds.token == ID_TOKEN_DATA
assert id_creds._include_email is True

def test_id_token_with_target_audience(
self, mock_donor_credentials, mock_authorizedsession_idtoken
Expand All @@ -460,12 +461,15 @@ def test_id_token_with_target_audience(
assert credentials.valid
assert not credentials.expired

id_creds = impersonated_credentials.IDTokenCredentials(credentials)
id_creds = impersonated_credentials.IDTokenCredentials(
credentials, include_email=True
)
id_creds = id_creds.with_target_audience(target_audience=target_audience)
id_creds.refresh(request)

assert id_creds.token == ID_TOKEN_DATA
assert id_creds.expiry == datetime.datetime.fromtimestamp(ID_TOKEN_EXPIRY)
assert id_creds._include_email is True

def test_id_token_invalid_cred(
self, mock_donor_credentials, mock_authorizedsession_idtoken
Expand Down