Skip to content

Commit 002f288

Browse files
liminwJon Wayne Parrott
authored andcommitted
Update auth config and README (GoogleCloudPlatform#805)
* Use 'security' directive instead of 'x-security'. Also add 'x-google' prefix to the existing auth swagger extensions. * Minor fixes.
1 parent 6b24174 commit 002f288

File tree

4 files changed

+56
-82
lines changed

4 files changed

+56
-82
lines changed

appengine/flexible/endpoints/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The JWT client demonstrates how to use a service account to authenticate to endp
7272

7373
To use the service account for authentication:
7474

75-
1. Update the `google_jwt`'s `x-jwks_uri` in `openapi.yaml` with your service account's email address.
75+
1. Update the `google_jwt`'s `x-google-jwks_uri` in `openapi.yaml` with your service account's email address.
7676
2. Redeploy your application.
7777

7878
Now you can use the JWT client to make requests to the API:
@@ -91,7 +91,7 @@ The ID Token client demonstrates how to use user credentials to authenticate to
9191

9292
To use the client ID for authentication:
9393

94-
1. Update the `/auth/info/googleidtoken`'s `audiences` in `openapi.yaml` with your client ID.
94+
1. Update the `google_id_token`'s `x-google-audiences` in `openapi.yaml` with your client ID.
9595
2. Redeploy your application.
9696

9797
Now you can use the client ID to make requests to the API:
@@ -106,7 +106,7 @@ We refer to the project that serves API requests as the server project. You also
106106

107107
To use the App Engine default service account for authentication:
108108

109-
1. Update the `gae_default_service_account`'s `x-issuer` and `x-jwks_uri` in `openapi.yaml` with your client project ID.
109+
1. Update the `gae_default_service_account`'s `x-google-issuer` and `x-google-jwks_uri` in `openapi.yaml` with your client project ID.
110110
2. Redeploy your server application.
111111
3. Update clients/service_to_service_gae_default/main.py, replace 'YOUR-CLIENT-PROJECT-ID' and 'YOUR-SERVER-PROJECT-ID' with your client project ID and your server project ID.
112112
4. Upload your application to Google App Engine by invoking the following command. Note that you need to provide project ID in the command because there are two projects (server and client projects) here and gcloud needs to know which project to pick.
@@ -137,7 +137,7 @@ Google API python client library should have already been installed under 'lib'
137137

138138
To use the client for authentication:
139139

140-
1. Update the `google_service_account`'s `x-issuer` and `x-jwks_uri` in `openapi.yaml` with your service account email.
140+
1. Update the `google_service_account`'s `x-google-issuer` and `x-google-jwks_uri` in `openapi.yaml` with your service account email.
141141
2. Redeploy your server application.
142142
3. Update clients/service_to_service_non_default/main.py by replacing 'YOUR-SERVICE-ACCOUNT-EMAIL', 'YOUR-SERVER-PROJECT-ID' and 'YOUR-CLIENT-PROJECT-ID'
143143
with your service account email, your server project ID, and your client project ID, respectively.

appengine/flexible/endpoints/openapi.yaml

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,10 @@ paths:
4343
description: "Authentication info."
4444
schema:
4545
$ref: "#/definitions/authInfoResponse"
46-
x-security:
47-
- google_jwt:
48-
audiences:
49-
# This must match the "aud" field in the JWT. You can add multiple
50-
# audiences to accept JWTs from multiple clients.
51-
- "echo.endpoints.sample.google.com"
52-
- gae_default_service_account:
53-
audiences:
54-
# This must match the "aud" field in the JWT. You can add multiple
55-
# audiences to accept JWTs from multiple clients.
56-
- "echo.endpoints.sample.google.com"
57-
- google_service_account:
58-
audiences:
59-
# This must match the "aud" field in the JWT. You can add multiple
60-
# audiences to accept JWTs from multiple clients.
61-
- "echo.endpoints.sample.google.com"
46+
security:
47+
- google_jwt: []
48+
- gae_default_service_account: []
49+
- google_service_account: []
6250
"/auth/info/googleidtoken":
6351
get:
6452
description: "Returns the requests' authentication information."
@@ -70,12 +58,8 @@ paths:
7058
description: "Authentication info."
7159
schema:
7260
$ref: "#/definitions/authInfoResponse"
73-
x-security:
74-
- google_id_token:
75-
audiences:
76-
# Your OAuth2 client's Client ID must be added here. You can add
77-
# multiple client IDs to accept tokens from multiple clients.
78-
- "YOUR-CLIENT-ID"
61+
security:
62+
- google_id_token: []
7963
"/auth/info/firebase":
8064
get:
8165
description: "Returns the requests' authentication information."
@@ -87,10 +71,8 @@ paths:
8771
description: "Authentication info."
8872
schema:
8973
$ref: "#/definitions/authInfoResponse"
90-
x-security:
91-
- firebase:
92-
audiences:
93-
- "YOUR-PROJECT-ID"
74+
security:
75+
- firebase: []
9476

9577
definitions:
9678
echoMessage:
@@ -104,14 +86,12 @@ definitions:
10486
email:
10587
type: "string"
10688

107-
# [START securityDef]
10889
securityDefinitions:
10990
# This section configures basic authentication with an API key.
11091
api_key:
11192
type: "apiKey"
11293
name: "key"
11394
in: "query"
114-
# [END securityDef]
11595
# This section configures authentication using Google API Service Accounts
11696
# to sign a json web token. This is mostly used for server-to-server
11797
# communication.
@@ -120,9 +100,11 @@ securityDefinitions:
120100
flow: "implicit"
121101
type: "oauth2"
122102
# This must match the 'iss' field in the JWT.
123-
x-issuer: "jwt-client.endpoints.sample.google.com"
103+
x-google-issuer: "jwt-client.endpoints.sample.google.com"
124104
# Update this with your service account's email address.
125-
x-jwks_uri: "https://www.googleapis.com/service_accounts/v1/jwk/YOUR-SERVICE-ACCOUNT-EMAIL"
105+
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/jwk/YOUR-SERVICE-ACCOUNT-EMAIL"
106+
# This must match the "aud" field in the JWT. You can add multiple audiences to accept JWTs from multiple clients.
107+
x-google-audiences: "echo.endpoints.sample.google.com"
126108
# This section configures authentication using Google App Engine default
127109
# service account to sign a json web token. This is mostly used for
128110
# server-to-server communication.
@@ -131,9 +113,10 @@ securityDefinitions:
131113
flow: "implicit"
132114
type: "oauth2"
133115
# Replace YOUR-CLIENT-PROJECT-ID with your client project ID.
134-
x-issuer: "YOUR-CLIENT-PROJECT-ID@appspot.gserviceaccount.com"
135-
# Replace YOUR-CLIENT-PROJECT-ID with your client project ID.
136-
x-jwks_uri: "https://www.googleapis.com/robot/v1/metadata/x509/YOUR-CLIENT-PROJECT-ID@appspot.gserviceaccount.com"
116+
x-google-issuer: "YOUR-CLIENT-PROJECT-ID@appspot.gserviceaccount.com"
117+
# Replace YOUR-CLIENT-PROJECT-ID with your client project ID
118+
x-google-jwks_uri: "https://www.googleapis.com/robot/v1/metadata/x509/YOUR-CLIENT-PROJECT-ID@appspot.gserviceaccount.com"
119+
x-google-audiences: "echo.endpoints.sample.google.com"
137120
# This section configures authentication using a service account
138121
# to sign a json web token. This is mostly used for server-to-server
139122
# communication.
@@ -142,22 +125,27 @@ securityDefinitions:
142125
flow: "implicit"
143126
type: "oauth2"
144127
# Replace YOUR-SERVICE-ACCOUNT-EMAIL with your service account email.
145-
x-issuer: "YOUR-SERVICE-ACCOUNT-EMAIL"
128+
x-google-issuer: "YOUR-SERVICE-ACCOUNT-EMAIL"
146129
# Replace YOUR-SERVICE-ACCOUNT-EMAIL with your service account email.
147-
x-jwks_uri: "https://www.googleapis.com/robot/v1/metadata/x509/YOUR-SERVICE-ACCOUNT-EMAIL"
130+
x-google-jwks_uri: "https://www.googleapis.com/robot/v1/metadata/x509/YOUR-SERVICE-ACCOUNT-EMAIL"
131+
# This must match the "aud" field in the JWT. You can add multiple audiences to accept JWTs from multiple clients.
132+
x-google-audiences: "echo.endpoints.sample.google.com"
148133
# This section configures authentication using Google OAuth2 ID Tokens.
149134
# ID Tokens can be obtained using OAuth2 clients, and can be used to access
150135
# your API on behalf of a particular user.
151136
google_id_token:
152137
authorizationUrl: ""
153138
flow: "implicit"
154139
type: "oauth2"
155-
x-issuer: "accounts.google.com"
156-
x-jwks_uri: "https://www.googleapis.com/oauth2/v1/certs"
140+
x-google-issuer: "accounts.google.com"
141+
x-google-jwks_uri: "https://www.googleapis.com/oauth2/v1/certs"
142+
# Your OAuth2 client's Client ID must be added here. You can add multiple client IDs to accept tokens form multiple clients.
143+
x-google-audiences: "YOUR-CLIENT-ID"
157144
# This section configures authentication using Firebase Auth.
158145
firebase:
159146
authorizationUrl: ""
160147
flow: "implicit"
161148
type: "oauth2"
162-
x-issuer: "https://securetoken.google.com/YOUR-PROJECT-ID"
163-
x-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com"
149+
x-google-issuer: "https://securetoken.google.com/YOUR-PROJECT-ID"
150+
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com"
151+
x-google-audiences: "YOUR-PROJECT-ID"

endpoints/getting-started/README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The JWT client demonstrates how to use a service account to authenticate to endp
6767

6868
To use the service account for authentication:
6969

70-
1. Update the `google_jwt`'s `x-jwks_uri` in `openapi.yaml` with your service account's email address.
70+
1. Update the `google_jwt`'s `x-google-jwks_uri` in `openapi.yaml` with your service account's email address.
7171
2. Redeploy your application.
7272

7373
Now you can use the JWT client to make requests to the API:
@@ -86,7 +86,7 @@ The ID Token client demonstrates how to use user credentials to authenticate to
8686

8787
To use the client ID for authentication:
8888

89-
1. Update the `/auth/info/googleidtoken`'s `audiences` in `openapi.yaml` with your client ID.
89+
1. Update the `google_id_token`'s `x-google-audiences` in `openapi.yaml`with your client ID.
9090
2. Redeploy your application.
9191

9292
Now you can use the client ID to make requests to the API:
@@ -101,7 +101,7 @@ We refer to the project that serves API requests as the server project. You also
101101

102102
To use the App Engine default service account for authentication:
103103

104-
1. Update the `gae_default_service_account`'s `x-issuer` and `x-jwks_uri` in `openapi.yaml` with your client project ID.
104+
1. Update the `gae_default_service_account`'s `x-google-issuer` and `x-google-jwks_uri` in `openapi.yaml` with your client project ID.
105105
2. Redeploy your server application.
106106
3. Update clients/service_to_service_gae_default/main.py, replace 'YOUR-CLIENT-PROJECT-ID' and 'YOUR-SERVER-PROJECT-ID' with your client project ID and your server project ID.
107107
4. Upload your application to Google App Engine by invoking the following command. Note that you need to provide project ID in the command because there are two projects (server and client projects) here and gcloud needs to know which project to pick.
@@ -132,7 +132,7 @@ Google API python client library should have already been installed under 'lib'
132132

133133
To use the client for authentication:
134134

135-
1. Update the `google_service_account`'s `x-issuer` and `x-jwks_uri` in `openapi.yaml` with your service account email.
135+
1. Update the `google_service_account`'s `x-google-issuer` and `x-google-jwks_uri` in `openapi.yaml` with your service account email.
136136
2. Redeploy your server application.
137137
3. Update clients/service_to_service_non_default/main.py by replacing 'YOUR-SERVICE-ACCOUNT-EMAIL', 'YOUR-SERVER-PROJECT-ID' and 'YOUR-CLIENT-PROJECT-ID'
138138
with your service account email, your server project ID, and your client project ID, respectively.
@@ -155,10 +155,8 @@ The client project is running Google App Engine standard application.
155155

156156
To use the client for authentication:
157157

158-
1. Update the `google_id_token`'s audiences, replace `YOUR-SERVER-PROJECT-ID` with your server project ID.
159-
2. Redeploy your server application.
160-
3. Update clients/service_to_service_google_id_token/main.py, replace 'YOUR-CLIENT-PROJECT-ID' and 'YOUR-SERVER-PROJECT-ID' with your client project ID and your server project ID.
161-
4. Upload your application to Google App Engine by invoking the following command. Note that you need to provide project ID in the command because there are two projects (server and client projects) here and gcloud needs to know which project to pick.
158+
1. Update clients/service_to_service_google_id_token/main.py, replace 'YOUR-CLIENT-PROJECT-ID' and 'YOUR-SERVER-PROJECT-ID' with your client project ID and your server project ID.
159+
2. Upload your application to Google App Engine by invoking the following command. Note that you need to provide project ID in the command because there are two projects (server and client projects) here and gcloud needs to know which project to pick.
162160
```bash
163161
$ gcloud app deploy app.yaml --project=YOUR-CLIENT-PROJECT-ID
164162
```

endpoints/getting-started/openapi.yaml

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,10 @@ paths:
4545
description: "Authentication info."
4646
schema:
4747
$ref: "#/definitions/authInfoResponse"
48-
x-security:
49-
- google_jwt:
50-
audiences:
51-
# This must match the "aud" field in the JWT. You can add multiple
52-
# audiences to accept JWTs from multiple clients.
53-
- "echo.endpoints.sample.google.com"
54-
- gae_default_service_account:
55-
audiences:
56-
# This must match the "aud" field in the JWT. You can add multiple
57-
# audiences to accept JWTs from multiple clients.
58-
- "echo.endpoints.sample.google.com"
59-
- google_service_account:
60-
audiences:
61-
# This must match the "aud" field in the JWT. You can add multiple
62-
# audiences to accept JWTs from multiple clients.
63-
- "echo.endpoints.sample.google.com"
48+
security:
49+
- google_jwt: []
50+
- gae_default_service_account: []
51+
- google_service_account: []
6452
"/auth/info/googleidtoken":
6553
get:
6654
description: "Returns the requests' authentication information."
@@ -72,13 +60,8 @@ paths:
7260
description: "Authentication info."
7361
schema:
7462
$ref: "#/definitions/authInfoResponse"
75-
x-security:
76-
- google_id_token:
77-
audiences:
78-
# Your OAuth2 client's Client ID must be added here. You can add
79-
# multiple client IDs to accept tokens from multiple clients.
80-
- "YOUR-CLIENT-ID"
81-
- "YOUR-SERVER-PROJECT-ID@appspot.gserviceaccount.com"
63+
security:
64+
- google_id_token: []
8265
"/auth/info/firebase":
8366
get:
8467
description: "Returns the requests' authentication information."
@@ -90,10 +73,8 @@ paths:
9073
description: "Authentication info."
9174
schema:
9275
$ref: "#/definitions/authInfoResponse"
93-
x-security:
94-
- firebase:
95-
audiences:
96-
- "YOUR-PROJECT-ID"
76+
security:
77+
- firebase: []
9778

9879
definitions:
9980
echoMessage:
@@ -107,14 +88,12 @@ definitions:
10788
email:
10889
type: "string"
10990

110-
# [START securityDef]
11191
securityDefinitions:
11292
# This section configures basic authentication with an API key.
11393
api_key:
11494
type: "apiKey"
11595
name: "key"
11696
in: "query"
117-
# [END securityDef]
11897
# This section configures authentication using Google API Service Accounts
11998
# to sign a json web token. This is mostly used for server-to-server
12099
# communication.
@@ -126,6 +105,8 @@ securityDefinitions:
126105
x-google-issuer: "jwt-client.endpoints.sample.google.com"
127106
# Update this with your service account's email address.
128107
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/jwk/YOUR-SERVICE-ACCOUNT-EMAIL"
108+
# This must match the "aud" field in the JWT. You can add multiple audiences to accept JWTs from multiple clients.
109+
x-google-audiences: "echo.endpoints.sample.google.com"
129110
# This section configures authentication using Google App Engine default
130111
# service account to sign a json web token. This is mostly used for
131112
# server-to-server communication.
@@ -137,6 +118,8 @@ securityDefinitions:
137118
x-google-issuer: "YOUR-CLIENT-PROJECT-ID@appspot.gserviceaccount.com"
138119
# Replace YOUR-CLIENT-PROJECT-ID with your client project ID.
139120
x-google-jwks_uri: "https://www.googleapis.com/robot/v1/metadata/x509/YOUR-CLIENT-PROJECT-ID@appspot.gserviceaccount.com"
121+
# This must match the "aud" field in the JWT. You can add multiple audiences to accept JWTs from multiple clients.
122+
x-google-audiences: "echo.endpoints.sample.google.com"
140123
# This section configures authentication using a service account
141124
# to sign a json web token. This is mostly used for server-to-server
142125
# communication.
@@ -145,9 +128,11 @@ securityDefinitions:
145128
flow: "implicit"
146129
type: "oauth2"
147130
# Replace YOUR-SERVICE-ACCOUNT-EMAIL with your service account email.
148-
x-issuer: "YOUR-SERVICE-ACCOUNT-EMAIL"
131+
x-google-issuer: "YOUR-SERVICE-ACCOUNT-EMAIL"
149132
# Replace YOUR-SERVICE-ACCOUNT-EMAIL with your service account email.
150-
x-jwks_uri: "https://www.googleapis.com/robot/v1/metadata/x509/YOUR-SERVICE-ACCOUNT-EMAIL"
133+
x-google-jwks_uri: "https://www.googleapis.com/robot/v1/metadata/x509/YOUR-SERVICE-ACCOUNT-EMAIL"
134+
# This must match the "aud" field in the JWT. You can add multiple audiences to accept JWTs from multiple clients.
135+
x-google-audiences: "echo.endpoints.sample.google.com"
151136
# This section configures authentication using Google OAuth2 ID Tokens.
152137
# ID Tokens can be obtained using OAuth2 clients, and can be used to access
153138
# your API on behalf of a particular user.
@@ -157,10 +142,13 @@ securityDefinitions:
157142
type: "oauth2"
158143
x-google-issuer: "accounts.google.com"
159144
x-google-jwks_uri: "https://www.googleapis.com/oauth2/v1/certs"
145+
# Your OAuth2 client's Client ID must be added here. You can add multiple client IDs to accept tokens form multiple clients.
146+
x-google-audiences: "YOUR-CLIENT-ID"
160147
# This section configures authentication using Firebase Auth.
161148
firebase:
162149
authorizationUrl: ""
163150
flow: "implicit"
164151
type: "oauth2"
165152
x-google-issuer: "https://securetoken.google.com/YOUR-PROJECT-ID"
166153
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com"
154+
x-google-audiences: "YOUR-PROJECT-ID"

0 commit comments

Comments
 (0)