Skip to content

Commit 0941ec5

Browse files
DOCSP-43343 Authorization and Authentication page (#18)
* DOCSP-43343 Authorization and Authentication page * DOCSP-43343 updates for SS' feedback * Apply suggestions from code review Co-authored-by: Sarah Simpers <[email protected]> * DOCSP-43343 updates for SS copy feedback * DOCSP-43343 updates for LA's feedback --------- Co-authored-by: Sarah Simpers <[email protected]>
1 parent 07e1168 commit 0941ec5

15 files changed

+671
-18
lines changed

source/auth.txt

Lines changed: 412 additions & 18 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
atlas dbusers create \
5+
--projectId "6698000acf48197e089e4085" \
6+
--username "MyRoleARN" \
7+
--awsIAMType "ROLE" \
8+
--role "clusterMonitor" \
9+
--scope "myCluster"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
atlas federatedAuthentication federationSettings identityProvider create oidc IDPName \
5+
--audience "api://12345678-1234-1234-1234-123456789abc" \
6+
--authorizationType "GROUP" \
7+
--clientId "abcdef12-3456-7890-abcd-ef1234567890" \
8+
--desc "MyOIDCProvider test" \
9+
--federationSettingsId "5d1113b25a115342acc2d1aa" \
10+
--groupsClaim "groups" \
11+
--idpType "WORKLOAD" \
12+
--issuerUri "https://sts.windows.net/12345678-1234-1234-1234-123456789abc/" \
13+
--userClaim "sub" \
14+
--associatedDomain "example.com"
15+
16+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
atlas dbusers create \
5+
--projectId "6698000acf48197e089e4085" \
6+
--username "okta/my-idp-group" \
7+
--role "readWrite,dbAdmin" \
8+
--oidcType "IDP_GROUP"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
atlas dbusers create \
5+
--projectId 6698000acf48197e089e4085 \
6+
--username "tempUser" \
7+
--password "securePassword" \
8+
--role "readWrite" \
9+
--scope "myCluster" \
10+
--deleteAfter "2025-02-01T12:00:00Z"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
resource "mongodbatlas_custom_db_role" "create_role" {
5+
project_id = var.project_id
6+
role_name = "my_custom_role"
7+
8+
actions {
9+
action = "UPDATE"
10+
resources {
11+
database_name = "myDb"
12+
}
13+
}
14+
actions {
15+
action = "INSERT"
16+
resources {
17+
database_name = "myDb"
18+
}
19+
}
20+
actions {
21+
action = "REMOVE"
22+
resources {
23+
database_name = "myDb"
24+
}
25+
}
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
resource "mongodbatlas_database_user" "oidc" {
5+
project_id = var.project_id
6+
username = "${mongodbatlas_federated_settings_identity_provider.oidc.idp_id}/${azurerm_user_assigned_identity.this.principal_id}"
7+
oidc_auth_type = "USER"
8+
auth_database_name = "$external" # required when using OIDC USER authentication
9+
10+
roles {
11+
role_name = "atlasAdmin"
12+
database_name = "admin"
13+
}
14+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. code-block:: shell
2+
:copyable: true
3+
4+
resource "mongodbatlas_database_user" "admin_user" {
5+
project_id = "6698000acf48197e089e4085"
6+
username = "adminUser"
7+
password = "securePassword" # Use a secure password
8+
auth_database_name = "admin"
9+
10+
roles {
11+
role_name = "atlasAdmin" # Admin role for the cluster
12+
database_name = "admin"
13+
}
14+
15+
roles {
16+
role_name = "readWriteAnyDatabase" # Project member rights
17+
database_name = "admin"
18+
}
19+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
# Connection string to use in this configuration
5+
locals {
6+
mongodb_uri = var.connection_strings[0]
7+
}
8+
9+
# Atlas organization details to use in the configuration
10+
data "mongodbatlas_federated_settings" "this" {
11+
org_id = var.org_id
12+
name = var.project_name
13+
project_id = var.project_id
14+
}
15+
16+
# Configure an identity provider for federated authentication
17+
resource "mongodbatlas_federated_settings_identity_provider" "oidc" {
18+
federation_settings_id = data.mongodbatlas_federated_settings.this.id
19+
audience = var.token_audience
20+
authorization_type = "USER"
21+
description = "oidc-for-azure"
22+
# e.g. "https://sts.windows.net/91405384-d71e-47f5-92dd-759e272cdc1c/"
23+
issuer_uri = "https://sts.windows.net/${azurerm_user_assigned_identity.this.tenant_id}/"
24+
idp_type = "WORKLOAD"
25+
name = "OIDC-for-azure"
26+
protocol = "OIDC"
27+
# groups_claim = null
28+
user_claim = "sub"
29+
}
30+
31+
resource "mongodbatlas_federated_settings_org_config" "this" {
32+
federation_settings_id = data.mongodbatlas_federated_settings.this.id
33+
org_id = var.org_id
34+
domain_restriction_enabled = false
35+
domain_allow_list = []
36+
data_access_identity_provider_ids = [mongodbatlas_federated_settings_identity_provider.oidc.idp_id]
37+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.. code-block:: shell
2+
:copyable: true
3+
4+
locals {
5+
test_user_password = random_password.password.result
6+
}
7+
8+
# Generates 12 characters long random password without special characters
9+
resource "random_password" "password" {
10+
length = 12
11+
special = false
12+
}
13+
14+
resource "mongodbatlas_database_user" "user1" {
15+
username = var.user[0]
16+
password = local.test_user_password
17+
project_id = var.project_id
18+
auth_database_name = "admin"
19+
scopes = var.clusters[0]
20+
21+
roles {
22+
role_name = "readWriteAny"
23+
database_name = var.database_name[0]
24+
}
25+
}
26+
27+
output "user1" { value = mongodbatlas_database_user.user1.username }
28+
output "userpwd" { value = mongodbatlas_database_user.user1.password sensitive = true }

0 commit comments

Comments
 (0)