@@ -1217,10 +1217,15 @@ in the MONGODB-OIDC specification, including sections or blocks that specificall
1217
1217
1218
1218
- PROVIDER_NAME \
1219
1219
Drivers MUST allow the user to specify the name of a built- in OIDC provider integration to use to
1220
- obtain credentials. If provided, the value MUST be one of `[" aws" ]` . If both `PROVIDER_NAME ` and an
1220
+ obtain credentials. If provided, the value MUST be one of `[" aws" , " azure " ]` . If both `PROVIDER_NAME ` and an
1221
1221
[OIDC Callback](# oidc-callback) or [OIDC Human Callback](#oidc-human-callback) are provided for the same
1222
1222
`MongoClient` , the driver MUST raise an error.
1223
1223
1224
+ - TOKEN_AUDIENCE \
1225
+ The URI of the target resource. This property is currently only used and required by the Azure
1226
+ built- in OIDC provider integration. If `TOKEN_AUDIENCE ` is provided and `PROVIDER_NAME ` is not `azure` or
1227
+ `TOKEN_AUDIENCE ` is not provided and `PROVIDER_NAME ` is `azure` , the driver MUST raise an error.
1228
+
1224
1229
- OIDC_CALLBACK \
1225
1230
An [OIDC Callback](# oidc-callback) that returns OIDC credentials. Drivers MAY allow the user to
1226
1231
specify an [OIDC Callback](# oidc-callback) using a `MongoClient` configuration instead of a mechanism property,
@@ -1250,9 +1255,9 @@ in the MONGODB-OIDC specification, including sections or blocks that specificall
1250
1255
1251
1256
Drivers MUST support all of the following built- in OIDC providers.
1252
1257
1253
- # ###### AWS
1258
+ ** AWS **
1254
1259
1255
- The AWS provider is enabled by setting auth mechanism property `PROVIDER_NAME :aws` .
1260
+ The AWS provider integration is enabled by setting auth mechanism property `PROVIDER_NAME :aws` .
1256
1261
1257
1262
If enabled, drivers MUST read the file path from environment variable `AWS_WEB_IDENTITY_TOKEN_FILE ` and then read the
1258
1263
OIDC access token from that file . The driver MUST use the contents of that file as value in the `jwt` field of the
@@ -1261,6 +1266,59 @@ OIDC access token from that file. The driver MUST use the contents of that file
1261
1266
Drivers MAY implement the AWS provider so that it conforms to the function signature of the
1262
1267
[OIDC Callback](# oidc-callback) to prevent having to re-implement the AWS provider logic in the OIDC prose tests.
1263
1268
1269
+ ** Azure**
1270
+
1271
+ The Azure provider integration is enabled by setting auth mechanism property `PROVIDER_NAME :azure` .
1272
+
1273
+ If enabled, drivers MUST call the
1274
+ [Azure Instance Metadata Service](https:// learn.microsoft.com/ en- us/ azure/ virtual- machines/ instance- metadata- service)
1275
+ and parse the JSON response body.
1276
+
1277
+ Make an HTTP GET request to
1278
+
1279
+ ```
1280
+ http:// 169.254 .169.254/ metadata/ identity/ oauth2/ token? api- version = 2018 - 02 - 01 & resource = < resource> & object_id = < object_id>
1281
+ ```
1282
+
1283
+ with headers
1284
+
1285
+ ```
1286
+ Accept: application/ json
1287
+ Metadata: true
1288
+ ```
1289
+
1290
+ where `< resource> ` is the value of the `TOKEN_AUDIENCE ` mechanism property and `< object_id> ` is the `username` from the
1291
+ connection string. If a `username` is not provided, the `object_id` query parameter should be omitted.
1292
+
1293
+ The curl recipe below demonstrates the above, where `$ TOKEN_AUDIENCE ` is the value of the `TOKEN_AUDIENCE ` mechanism
1294
+ property .
1295
+
1296
+ ```bash
1297
+ curl - X GET \
1298
+ - H " Accept: application/json" \
1299
+ - H " Metadata: true" \
1300
+ " http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=$TOKEN_AUDIENCE"
1301
+ ```
1302
+
1303
+ The JSON response will be in this format :
1304
+
1305
+ ```json
1306
+ {
1307
+ " access_token" : " eyJ0eXAi..." ,
1308
+ " refresh_token" : " " ,
1309
+ " expires_in" : " 3599" ,
1310
+ " expires_on" : " 1506484173" ,
1311
+ " not_before" : " 1506480273" ,
1312
+ " resource" : " https://management.azure.com/" ,
1313
+ " token_type" : " Bearer"
1314
+ }
1315
+ ```
1316
+
1317
+ The driver MUST use the returned `" access_token" ` value as the access token in a `JwtStepRequest` .
1318
+
1319
+ For more details, see
1320
+ [How to use managed identities for Azure resources on an Azure VM to acquire an access token](https:// learn.microsoft.com/ en- us/ entra/ identity/ managed- identities- azure- resources/ how- to- use- vm- token).
1321
+
1264
1322
# ### OIDC Callback
1265
1323
1266
1324
Drivers MUST allow users to provide a callback that returns an OIDC access token. The purpose of the callback is to
@@ -1572,7 +1630,7 @@ def invalidate(access_token):
1572
1630
Drivers that support the [Human Authentication Flow](# human-authentication-flow) MUST also cache the `IdPInfo` and
1573
1631
refresh token in the * Client Cache* when a [OIDC Human Callback](# oidc-human-callback) is configured.
1574
1632
1575
- # ###### Authentication
1633
+ ** Authentication**
1576
1634
1577
1635
Use the following algorithm to authenticate a new connection:
1578
1636
@@ -1919,6 +1977,8 @@ to EC2 instance metadata in ECS, for security reasons, Amazon states it's best p
1919
1977
1920
1978
# # Changelog
1921
1979
1980
+ - 2024 - 02 - 21 : Added Azure built- in OIDC provider integration.
1981
+
1922
1982
- 2024 - 01 - 31 : Migrated from reStructuredText to Markdown.
1923
1983
1924
1984
- 2024 - 01 - 17 : Added MONGODB - OIDC machine auth flow spec and combine with human\
0 commit comments