@@ -1214,14 +1214,15 @@ in the MONGODB-OIDC specification, including sections or blocks that specificall
1214
1214
1215
1215
- ENVIRONMENT \
1216
1216
Drivers MUST allow the user to specify the name of a built- in OIDC application environment integration
1217
- to use to obtain credentials. If provided, the value MUST be one of `[" test" , " azure" ]` . If both ` ENVIRONMENT ` and
1218
- an [OIDC Callback](# oidc-callback) or [OIDC Human Callback](#oidc-human-callback) are provided for the same
1219
- `MongoClient` , the driver MUST raise an error.
1217
+ to use to obtain credentials. If provided, the value MUST be one of `[" test" , " azure" , " gcp " ]` . If both
1218
+ ` ENVIRONMENT ` and an [OIDC Callback](# oidc-callback) or [OIDC Human Callback](#oidc-human-callback) are provided for
1219
+ the same `MongoClient` , the driver MUST raise an error.
1220
1220
1221
1221
- TOKEN_RESOURCE \
1222
1222
The URI of the target resource. This property is currently only used and required by the Azure
1223
- built- in OIDC provider integration. If `TOKEN_RESOURCE ` is provided and `ENVIRONMENT ` is not `azure` or
1224
- `TOKEN_RESOURCE ` is not provided and `ENVIRONMENT ` is `azure` , the driver MUST raise an error.
1223
+ built- in OIDC provider integration. If `TOKEN_RESOURCE ` is provided and `ENVIRONMENT ` is not one of
1224
+ `[" azure" , " gcp" ]` or `TOKEN_RESOURCE ` is not provided and `ENVIRONMENT ` is one of `[" azure" , " gcp" ]` , the driver
1225
+ MUST raise an error.
1225
1226
1226
1227
- OIDC_CALLBACK \
1227
1228
An [OIDC Callback](# oidc-callback) that returns OIDC credentials. Drivers MAY allow the user to
@@ -1326,6 +1327,67 @@ For more details, see
1326
1327
The callback itself MUST not perform any caching, and the driver MUST cache its tokens in the same way as if a custom
1327
1328
callback had been provided by the user.
1328
1329
1330
+ For details on test environment setup, see the README in
1331
+ [Drivers- Evergreen- Tools](https:// github.com/ mongodb- labs/ drivers- evergreen- tools/ blob/ master/ .evergreen/ auth_oidc/ azure/ README .md).
1332
+
1333
+ ** GCP **
1334
+
1335
+ The GCP provider integration is enabled by setting auth mechanism property `ENVIRONMENT :gcp` .
1336
+
1337
+ If enabled, drivers MUST use an internal machine callback that calls the
1338
+ [Google Cloud VM metadata](https:// cloud.google.com/ compute/ docs/ metadata/ overview) endpoint and parse the JSON response
1339
+ body, as follows:
1340
+
1341
+ Make an HTTP GET request to
1342
+
1343
+ ```
1344
+ http:// metadata/ computeMetadata/ v1/ instance/ service- accounts/ default/ identity? audience=< resource>
1345
+ ```
1346
+
1347
+ with headers
1348
+
1349
+ ```
1350
+ Accept: application/ json
1351
+ Metadata- Flavor: Google
1352
+ ```
1353
+
1354
+ where `< resource> ` is the value of the `TOKEN_RESOURCE ` mechanism property . The timeout should equal the
1355
+ `callbackTimeoutMS` parameter given to the callback.
1356
+
1357
+ Example code for the above using curl, where `$ TOKEN_RESOURCE ` is the value of the `TOKEN_RESOURCE ` mechanism property .
1358
+
1359
+ ```bash
1360
+ curl - X GET \
1361
+ - H " Accept: application/json" \
1362
+ - H " Metadata-Flavor: Google" \
1363
+ -- max - time $ CALLBACK_TIMEOUT_MS \
1364
+ " http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience=$TOKEN_RESOURCE"
1365
+ ```
1366
+
1367
+ The JSON response will be in this format :
1368
+
1369
+ ```json
1370
+ {
1371
+ " aud" : " https://example.com" ,
1372
+ " azp" : " 118153013249117554930" ,
1373
+ " exp" : 1707488566 ,
1374
+ " iat" : 1707484966 ,
1375
+ " iss" : " https://accounts.google.com" ,
1376
+ " sub" : " 118153013249117554930"
1377
+ }
1378
+ ```
1379
+
1380
+ The driver MUST use the returned `" access_token" ` value as the access token in a `JwtStepRequest` . If the response does
1381
+ not return a status code of 200 , the driver MUST raise an error including the HTTP response body.
1382
+
1383
+ For more details, see [View and query VM metadata](https:// cloud.google.com/ compute/ docs/ metadata/ querying- metadata).
1384
+
1385
+ The callback itself MUST not perform any caching, and the driver MUST cache its tokens in the same way as if a custom
1386
+ callback had been provided by the user.
1387
+
1388
+ For details on test environment setup, see the README in
1389
+ [Drivers- Evergreen- Tools](https:// github.com/ mongodb- labs/ drivers- evergreen- tools/ blob/ master/ .evergreen/ auth_oidc/ gcp/ README .md).
1390
+
1329
1391
# ### OIDC Callback
1330
1392
1331
1393
Drivers MUST allow users to provide a callback that returns an OIDC access token. The purpose of the callback is to
@@ -1988,6 +2050,8 @@ to EC2 instance metadata in ECS, for security reasons, Amazon states it's best p
1988
2050
1989
2051
# # Changelog
1990
2052
2053
+ - 2024 - 04 - 03 : Added GCP built- in OIDC provider integration.
2054
+
1991
2055
- 2024 - 03 - 29 : Updated OIDC test setup and descriptions.
1992
2056
1993
2057
- 2024 - 03 - 21 : Added Azure built- in OIDC provider integration.
0 commit comments