Skip to content

Commit 32d4517

Browse files
chore(deps): bump requests from 2.31.0 to 2.32.2 in /iap (GoogleCloudPlatform#11891)
* chore(deps): bump requests from 2.31.0 to 2.32.2 in /iap Bumps [requests](https://github.com/psf/requests) from 2.31.0 to 2.32.2. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](psf/requests@v2.31.0...v2.32.2) --- updated-dependencies: - dependency-name: requests dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent c93acca commit 32d4517

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

iap/generate_self_signed_jwt.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ def generate_jwt_payload(service_account_email: str, resource_url: str) -> str:
3737
"""
3838
iat = datetime.datetime.now(tz=datetime.timezone.utc)
3939
exp = iat + 3600
40-
return json.dumps({
41-
'iss': service_account_email,
42-
'sub': service_account_email,
43-
'aud': resource_url,
44-
'iat': iat,
45-
'exp': exp,
46-
})
40+
return json.dumps(
41+
{
42+
"iss": service_account_email,
43+
"sub": service_account_email,
44+
"aud": resource_url,
45+
"iat": iat,
46+
"exp": exp,
47+
}
48+
)
49+
50+
4751
# [END iap_generate_self_signed_jwt]
4852
# [START iap_sign_jwt_IAM]
4953

@@ -62,9 +66,11 @@ def sign_jwt(target_sa: str, resource_url: str) -> str:
6266
source_credentials, _ = google.auth.default()
6367
iam_client = iam_credentials_v1.IAMCredentialsClient(credentials=source_credentials)
6468
return iam_client.sign_jwt(
65-
name=iam_client.service_account_path('-', target_sa),
69+
name=iam_client.service_account_path("-", target_sa),
6670
payload=generate_jwt_payload(target_sa, resource_url),
6771
).signed_jwt
72+
73+
6874
# [END iap_sign_jwt_IAM]
6975
# [START iap_sign_jwt_with_key_file]
7076

@@ -79,24 +85,28 @@ def sign_jwt_with_key_file(credential_key_file_path: str, resource_url: str) ->
7985
Returns:
8086
A self-signed JWT created with a downloaded private key.
8187
"""
82-
with open(credential_key_file_path, 'r') as credential_key_file:
88+
with open(credential_key_file_path, "r") as credential_key_file:
8389
key_data = json.load(credential_key_file)
8490

8591
PRIVATE_KEY_ID_FROM_JSON = key_data["private_key_id"]
8692
PRIVATE_KEY_FROM_JSON = key_data["private_key"]
8793
SERVICE_ACCOUNT_EMAIL = key_data["client_email"]
8894

8995
# Sign JWT with private key and store key id in the header
90-
additional_headers = {'kid': PRIVATE_KEY_ID_FROM_JSON}
91-
payload = generate_jwt_payload(service_account_email=SERVICE_ACCOUNT_EMAIL, resource_url=resource_url)
96+
additional_headers = {"kid": PRIVATE_KEY_ID_FROM_JSON}
97+
payload = generate_jwt_payload(
98+
service_account_email=SERVICE_ACCOUNT_EMAIL, resource_url=resource_url
99+
)
92100

93101
signed_jwt = jwt.encode(
94102
payload,
95103
PRIVATE_KEY_FROM_JSON,
96104
headers=additional_headers,
97-
algorithm='RS256',
105+
algorithm="RS256",
98106
)
99107
return signed_jwt
108+
109+
100110
# [END iap_sign_jwt_with_key_file]
101111

102112
# sign_jwt("test_email", "resource-url")

iap/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cryptography==42.0.5
22
Flask==3.0.3
33
google-auth==2.19.1
44
gunicorn==22.0.0
5-
requests==2.31.0
5+
requests==2.32.2
66
requests-toolbelt==1.0.0
77
Werkzeug==3.0.3
88
google-cloud-iam~=2.3.0

0 commit comments

Comments
 (0)