mongodb_atlas_identity_provider
Beta
Direct

Mongodb Atlas MongoDB Identity Provider

This module sets up the identity provider configuration in MongoDB Atlas.

Panfactum Role to MongoDB Atlas Role Mapping

This document outlines the default role mappings between Panfactum Roles and MongoDB Atlas Roles. The mappings ensure that users in Panfactum have appropriate permissions in MongoDB Atlas, maintaining security and role-based access control.

For more details on MongoDB Atlas roles, refer to the official documentation:
MongoDB Atlas User Roles

Panfactum RoleMongoDB Atlas Role(s)Reason for Mapping
superusersORG_OWNERSuperusers require full administrative access to the MongoDB Atlas organization, including user management, billing, and resource creation.
privileged_engineersORG_OWNERPrivileged engineers act as admins, enabling them to fully manage Atlas independently without relying on Panfactum.
billing_adminsORG_BILLING_ADMINBilling admins manage payment details and invoices but do not need full administrative control over the organization.
engineersORG_READ_ONLYEngineers require read-only access to view Atlas organization settings but cannot modify any configurations.
restricted_engineersORG_MEMBERRestricted engineers have basic membership access, allowing them to work within assigned projects but without organization-wide privileges.

Guide

Pre-req: Setup MongoDB Atlas Identity Provider Domain Verification

  1. Go to your MongoDB Atlas account
  2. Go to Organization Settings -> Federated Authentication Settings -> Domains
  3. Click on Add Domain Add Domain
  4. Add the root domain that you are using for Authentik (i.e., panfactum.com)
  5. Select DNS Record as the verification method DNS Verification
  6. Note the TXT Record that is generated. You will need this value in future steps. DNS TXT Verification Record

Deploy a new DNS TXT Record & Verify

  1. Add a text record to your global/aws_dns/terragrunt.hcl file that looks like this.
  2. Run terragrunt apply
  3. Go back to MongoDB Atlas and click on Verify next to the domain you added
  4. Confirm verification

Download the Signing Certificate from Authentik

Before proceeding, make sure to have downloaded the signing certificate from the Authentik application

  1. Login to your Authentik instance
  2. Switch over to the Admin section Authentik Admin
  3. Go to the section Applications -> Providers -> MongoDB Atlas
  4. Find Related objects and click on the Download button for the Download signing certificate Authentik Identity Provider Signature

Deploy the MongoDB Identity Provider module

Unfortunately, the terraform provider for MongoDB Atlas does not support the creation of the Identity Provider but allows for modifications. We will first create the resource through the UI and then import it to configure further.

1. From MongoDB Atlas UI

  1. Go to Organization Settings
  2. Note the Organization ID. You will need this value in future steps.
  3. Go to Federated Authentication Settings -> Identity Providers
  4. Click on Configure Identity Provider Configure Identity Provider
  5. Select Workforce Identity Federation
  6. Select SAML for Atlas UI Access
  7. Set a Name such as Authentik Integration
  8. Click on Fill with placeholder values for the Issuer URI and Single Sign-On URL Fill with placeholder values
  9. Upload the Signing Certificate that we downloaded above
  10. Set the Request Binding to HTTP-POST
  11. Set the Response Signature Algorithm to SHA-256
  12. Continue to the next step and note these values as you will need them in future steps.
    • ACS URL
    • Audience URI
    • IdP ID
    • Federation Settings ID (Found in the url https://cloud.mongodb.com/v2#/federation/<this-is-your-federation-settings-id>/overview)

2. Create Access Keys

  1. Go to Organization Settings -> Access Manager
  2. Click on Applications tab
  3. Click on Add new
  4. Set the description to terraform
  5. Set the Organization Permission to Organization Owner
  6. Save the public and private key to your .env file
    1. Set MONGODB_ATLAS_PUBLIC_KEY
    2. Set MONGODB_ATLAS_PRIVATE_KEY

3. From the terminal

  1. Add a new a mongodb_atlas_identity_provider folder adjacent to your authentik_core_resources folder
  2. Add a new a terragrunt.hcl file that looks like this
  3. Set the federation_settings_id to the value from above
  4. Set the organization_id to the value from above
  5. Set the idp_id to the value from above
  6. Set the associated_domains by adding the domain you verified above to the list
  7. Set the sso_debug_enabled to true
  8. Run pf-tf-init
  9. Run terragrunt apply

4. CICD (Optional)

If you have CICD setup and deploying infrastructure using the wf_tf_deploy module, you will also need to pass in the keys.

  1. Update your CICD module var to accept the keys as inputs like this
  2. Update the wf_tf_deploy module and pass in the secrets inputs like this
  3. Add them to the secrets.yaml like this
  4. Utilize and pass them in as inputs like this

If you are following the authentik_mongodb_atlas_sso module guide, please return and resume the Sync Authentik with the Atlas Settings section.

Disable SSO Bypass

After you have confirmed and validated that SSO is working through Authentik, disable the Bypass SAML Mode toggle by updating the sso_debug_enabled to false in the mongodb_atlas_identity_provider module.

Providers

The following providers are needed by this module:

Required Inputs

The following input variables are required:

federation_settings_id

Description: The IDP ID from MongoDB Atlas

Type: string

idp_id

Description: The IDP ID from MongoDB Atlas

Type: string

issuer_url

Description: The issuer URL

Type: string

organization_id

Description: ID of the MongoDB Atlas organization

Type: string

sso_url

Description: The SSO URL

Type: string

Optional Inputs

The following input variables are optional (have default values):

active

Description: The status of the identity provider in MongoDB Atlas. Setting to false will disable the identity provider and SSO will not function.

Type: bool

Default: true

associated_domains

Description: The domains associated with the identity provider

Type: list(string)

Default: []

extra_role_mappings

Description: Extra authentik roles to map to MongoDB Atlas roles. {<panfactum role> => [<mongodb role>, ...]}

Type: map(list(string))

Default: {}

name

Description: The name of the identity provider

Type: string

Default: "Panfactum Authentik Integration"

sso_debug_enabled

Description: Enable SSO debug. This allows users to login with a password bypassing the SSO flow.

Type: bool

Default: true

Outputs

The following outputs are exported:

acs_url

Description: Assertion consumer service URL to which the IdP sends the SAML response

Maintainer Notes

No notes