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