@@ -1217,10 +1217,15 @@ in the MONGODB-OIDC specification, including sections or blocks that specificall
12171217
12181218 - PROVIDER_NAME \
12191219 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
12211221 [OIDC Callback](# oidc-callback) or [OIDC Human Callback](#oidc-human-callback) are provided for the same
12221222 `MongoClient` , the driver MUST raise an error.
12231223
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+
12241229 - OIDC_CALLBACK \
12251230 An [OIDC Callback](# oidc-callback) that returns OIDC credentials. Drivers MAY allow the user to
12261231 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
12501255
12511256Drivers MUST support all of the following built- in OIDC providers.
12521257
1253- # ###### AWS
1258+ ** AWS **
12541259
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` .
12561261
12571262If enabled, drivers MUST read the file path from environment variable `AWS_WEB_IDENTITY_TOKEN_FILE ` and then read the
12581263OIDC 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
12611266Drivers MAY implement the AWS provider so that it conforms to the function signature of the
12621267[OIDC Callback](# oidc-callback) to prevent having to re-implement the AWS provider logic in the OIDC prose tests.
12631268
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+
12641322# ### OIDC Callback
12651323
12661324Drivers 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):
15721630Drivers that support the [Human Authentication Flow](# human-authentication-flow) MUST also cache the `IdPInfo` and
15731631refresh token in the * Client Cache* when a [OIDC Human Callback](# oidc-human-callback) is configured.
15741632
1575- # ###### Authentication
1633+ ** Authentication**
15761634
15771635Use the following algorithm to authenticate a new connection:
15781636
@@ -1919,6 +1977,8 @@ to EC2 instance metadata in ECS, for security reasons, Amazon states it's best p
19191977
19201978# # Changelog
19211979
1980+ - 2024 - 02 - 21 : Added Azure built- in OIDC provider integration.
1981+
19221982- 2024 - 01 - 31 : Migrated from reStructuredText to Markdown.
19231983
19241984- 2024 - 01 - 17 : Added MONGODB - OIDC machine auth flow spec and combine with human\
0 commit comments