You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* refactor(pubsub): verify authenticated push requests
* refactor: remove iss claim check
* refactor: move authenticated sample to new region
* docs: update README to include authenticated push info
* refactor: remove async keyword
* doc: remove beta for topic creation
* docs: move authenticated push setup to separate step
* docs: add section on how to deploy app
* refactor: use regex to get bearer token
1. Create a subscription for authenticated pushes. The push auth service account must have Service Account Token Creator Role assigned, which can be done in the Cloud Console [IAM & admin](https://console.cloud.google.com/iam-admin/iam) UI. `--push-auth-token-audience` is optional. If set, remember to modify the audience field check in `app.js` (line 112).
1. Update the environment variables in `app.standard.yaml` or `app.flexible.yaml`
22
32
(depending on your App Engine environment).
23
33
@@ -61,3 +71,33 @@ Response:
61
71
62
72
After the request completes, you can refresh `localhost:8080` and see the
63
73
message in the list of received messages.
74
+
75
+
### Authenticated push notifications
76
+
77
+
Simulating authenticated push requests will fail because requests need to contain a Cloud Pub/Sub-generated JWT in the "Authorization" header.
78
+
79
+
http POST ":8080/pubsub/authenticated-push?token=<your-verification-token>" < sample_message.json
80
+
81
+
Response:
82
+
83
+
HTTP/1.1 400 Bad Request
84
+
Connection: keep-alive
85
+
Date: Thu, 25 Apr 2019 17:47:36 GMT
86
+
Transfer-Encoding: chunked
87
+
X-Powered-By: Express
88
+
89
+
Invalid token
90
+
91
+
## Running on App Engine
92
+
93
+
Note: Not all the files in the current directory are needed to run your code on App Engine. Specifically, the `test` directory, which is for testing purposes only. It SHOULD NOT be included in when deploying your app. When your app is up and running, Cloud Pub/Sub creates tokens using a private key, then the Google Auth Node.js library takes care of verifying and decoding the token using Google's public certs, to confirm that the push requests indeed come from Cloud Pub/Sub.
94
+
95
+
In the current directory, deploy using `gcloud`:
96
+
97
+
gcloud app deploy app.standard.yaml
98
+
99
+
To deploy to App Engine Node.js Flexible Environment, run
100
+
101
+
gcloud app deploy app.flexible.yaml
102
+
103
+
You can now access the application at https://[your-app-id].appspot.com. You can use the form to submit messages, but it's non-deterministic which instance of your application will receive the notification. You can send multiple messages and refresh the page to see the received message.
0 commit comments