For AI agents: a documentation index is available at https://www.mongodb.com/pt-br/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Authorize Users with Workforce Identity Federation

You can add a database user to MongoDB using Workforce authentication. This process allows your organization’s IdP to manage user access, ensuring secure and centralized authentication for database operations.

Note

Your oidcIdentityProviders configuration determines the approach you must take to authorize users:

  • If the useAuthorizationClaim field is set to false to enable internal authorization, authorize users with user IDs.

  • If the field is set to true, authorize users with IdP groups.

1

In the admin database, use the db.createRole() method to create roles that map the IdP group roles to MongoDB roles.

Use the following format to create roles:

<authNamePrefix>/<authorizationClaim>

The oidcIdentityProviders parameter provides the authNamePrefix field and the authorizationClaim field. For example:

db.createRole( {
role: "okta/Everyone",
privileges: [ ],
roles: [ "readWriteAnyDatabase" ]
} )

You can connect an application to MongoDB using Workforce Identity Federation in the following ways: