Docs Menu

Docs HomeLaunch & Manage MongoDBMongoDB Atlas

Set Up User Authentication and Authorization with OIDC/OAuth2.0

On this page

  • Required Access
  • Prerequisites
  • Procedures
  • Authenticate for a User or Group of Users
  • Configure An External Identity Provider Application
  • Configure Microsoft Entra ID as an Identity Provider
  • Delete OIDC Configuration
  • Revoke JWKS

You can authenticate and authorize access to Atlas for both employees and applications with your own identity provider supporting OIDC. You can configure user access with Workforce Identity Federation, and you can configure application access with Workload Identity Federation. See the following table for a comparison of the OIDC access options.

Authentication method
User type
Access type
Supported protocols
Workforce Identity Federation
Human users
Atlas UI Access, Database Access
OIDC, SAML
Workload Identity Federation
Programmatic users
Database Access
OAuth2.0

Select the authentication method to learn more:

To manage OIDC configuration, you must have Organization Owner access to Atlas.

To manage user authentication and authorization using OIDC in Atlas, you must map one or more domains to your Identity Provider.

Important

You configure Workforce Identity Federation in two stages. To link your IdP to Atlas:

  • Configure your IdP and save its metadata.

  • Set the metadata from your IdP to Atlas.

For both Workload Identity Federation and Workforce Identity Federation, you can grant authorization for either a group of users who will each have the same permissions, or for a single user.

Complete the following steps to create an OIDC entry for multiple users with the same permissions:

1

Select the Group Membership option in the Configure Identity Provider flow.

2

Update the Group Claim and the User Claim default values of group and sub respectively as needed to align with your externally configured OIDC provider.

Complete the following steps to create an OIDC entry for a single user:

1

Select the User ID option in the Configure Identity Provider flow.

2

Update the User Claim default value of sub as needed to align with your externally configured OIDC provider.

To configure Workforce Identity Federation with OIDC, you must first register your OIDC or OAuth application with an IdP that supports OIDC standard, such as Microsoft Entra ID, Okta, or Ping Identity.

You configure your OIDC application for the following grant types:

  • Authorization Code Flow with PKCE and/or

  • Device Authorization Flow.

MongoDB recommends using Authorization Code Flow with PKCE for better security posture. Use Device Authorization Flow only if your users need to access the database from machines with no browser.

OIDC application registration steps can vary based on your IdP. Ensure that you complete the following items during your registration process:

1

Make sure to select public client/native application as the client type.

2
3

This assures that your access tokens contain the group membership information of the user authenticating. MongoDB uses the values sent in groups claim for authorization.

4

(Optional) Allow refresh tokens if you want MongoDB clients to refresh the tokens for a better user experience.

5

(Optional) Configure access token lifetime (exp claim) to align with your database connection session time.

Once you register your application, save the issuer, clientId and audience values to use in the next stage of the Atlas OIDC IdP configuration.

To register your OIDC or OAuth application with Microsoft Entra ID:

1
1
2
2
3
Field
Value
Name
Atlas Database - OIDC
Supported Account Types
Accounts in this organizational directory only (single tenant)
Redirect URI
- Public client/native (mobile & desktop)
- http://localhost:27097/redirect
4

To learn more about registering an application, see Azure Documentation.

2
1

In the Manage section of the left navigation, click Token Configuration.

2
3

What groups you select depend on the type of groups you configured in your Azure environment. You may need to select a different type of group to send the appropriate group information.

4

When you select Group Id, Azure sends the security group's Object ID.

5

To learn more about adding a group claim, see Azure Documentation.

3
1
2
3

Select a claim that carries a user identifier that you can refer to in MongoDB access logs such as an email.

4
5

To learn more, see Azure Documentation.

4
1
2

The number 2 represents Version 2 of Microsoft's access tokens. Other applications can use this as a signed attestation of the Active Directory-managed user's identity. Version 2 ensures that the token is a JSON Web Token that MongoDB understands.

3

To learn more about adding an optional claim, see Azure Documentation.

5
1

Copy the Application (client) ID value.

2

Copy the OpenID Connect metadata document value without the /.well-known/openid-configuration part.

You can also retrieve this value by following the OpenID Connect metadata document URL and copying the value for issuer.

The following table shows what these Microsoft Entra ID UI values map to in our Atlas Configuration Properties:

Microsoft Entra ID UI
Atlas Configuration Property
Application (client) ID
Client ID
Audience
OpenID Connect metadata document (without /.well-known/openid-configuration)
Issuer URI.

To delete your OIDC configuration, you must:

1
1
1
  1. If it is not already displayed, select your desired organization from the Organizations menu in the navigation bar.

  2. Click the Organization Settings icon next to the Organizations menu.

2

In the Setup Federated Login or Manage Federation Settings section, click Visit Federation Management App.

2
3
4
5

In the Disconnect identity provider? modal, click Disconnect.

When you disconnect an IdP, users who authenticate using the IdP will lose access to OIDC in the Atlas projects listed in the Project table.

2

Click Identity Providers in the left side navigation bar.

3
4

In the Delete Identity Provider? modal, click Delete.

Note

Don't use this feature to rotate your signing keys. When you rotate your OIDC Identity Provider signing keys, MongoDB fetches the JWKS automatically upon expiration of the existing access tokens.

If your private key is compromised, you can immediately revoke your JSON Web Key Sets (JWKS) cached in MongoDB nodes:

1
2
1
  1. If it is not already displayed, select your desired organization from the Organizations menu in the navigation bar.

  2. Click the Organization Settings icon next to the Organizations menu.

2

In the Setup Federated Login or Manage Federation Settings section, click Visit Federation Management App.

3
4
5

After you click Revoke, MongoDB fetches the new keys through your JWKS endpoint. You must restart your clients (such as MongoDB Shell or Compass) after revoking JWKS.

← Configure User Authentication and Authorization with OneLogin VLDAP