Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c81a944

Browse filesBrowse files
fayssalmartanigcpgcf-merge-on-green[bot]engelke
authored
Add comment about authenticated push JWT token validation (GoogleCloudPlatform#5729)
This snippet is used in the Cloud Pub/Sub docs (https://cloud.google.com/pubsub/docs/push#validating_tokens) and many users are not aware that signature verification of the token is not enough, the claim needs to be validated also. Co-authored-by: gcf-merge-on-green[bot] <60162190+gcf-merge-on-green[bot]@users.noreply.github.com> Co-authored-by: Charles Engelke <engelke@google.com>
1 parent 50afaf0 commit c81a944
Copy full SHA for c81a944

File tree

Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed
Filter options
  • appengine/standard_python3/pubsub
Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed

‎appengine/standard_python3/pubsub/main.py

Copy file name to clipboardExpand all lines: appengine/standard_python3/pubsub/main.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ def receive_messages_handler():
8585
# case they would all share the same token for a limited time window.
8686
claim = id_token.verify_oauth2_token(token, requests.Request(),
8787
audience='example.com')
88+
89+
# IMPORTANT: you should validate claim details not covered by signature
90+
# and audience verification above, including:
91+
# - Ensure that `claim["email"]` is equal to the expected service
92+
# account set up in the push subscription settings.
93+
# - Ensure that `claim["email_verified"]` is set to true.
94+
8895
CLAIMS.append(claim)
8996
except Exception as e:
9097
return 'Invalid token: {}\n'.format(e), 400

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.