Skip to content

Commit 6b0a799

Browse files
authored
Merge pull request #110484 from lfittl-msft/lufittl/aad-postgres-explain-elevated-permissions
AAD Postgres: Clarify that AAD admin has elevated permissions, re-order page flow
2 parents 778ea8a + 3b579fe commit 6b0a799

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

articles/postgresql/howto-configure-sign-in-aad-authentication.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ This article will walk you through the steps how to configure Azure Active Direc
1919
2020
## Setting the Azure AD Admin user
2121

22-
Only an Azure AD Admin user can create/enable users for Azure AD-based authentication. To create and Azure AD Admin user, please follow the following steps
22+
Only Azure AD administrator users can create/enable users for Azure AD-based authentication. We recommend not using the Azure AD administrator for regular database operations, as it has elevated user permissions (e.g. CREATEDB).
23+
24+
To set the Azure AD administrator (you can use a user or a group), please follow the following steps
2325

2426
1. In the Azure portal, select the instance of Azure Database for PostgreSQL that you want to enable for Azure AD.
2527
2. Under Settings, select Active Directory Admin:
@@ -33,36 +35,6 @@ Only an Azure AD Admin user can create/enable users for Azure AD-based authentic
3335
3436
Only one Azure AD admin can be created per PostgreSQL server and selection of another one will overwrite the existing Azure AD admin configured for the server. You can specify an Azure AD group instead of an individual user to have multiple administrators. Note that you will then sign in with the group name for administration purposes.
3537

36-
## Creating Azure AD users in Azure Database for PostgreSQL
37-
38-
To add an Azure AD user to your Azure Database for PostgreSQL database, perform the following steps after connecting (see later section on how to connect):
39-
40-
1. First ensure that the Azure AD user `<user>@yourtenant.onmicrosoft.com` is a valid user in Azure AD tenant.
41-
2. Sign in to your Azure Database for PostgreSQL instance as the Azure AD Admin user.
42-
3. Create role `<user>@yourtenant.onmicrosoft.com` in Azure Database for PostgreSQL.
43-
4. Make `<user>@yourtenant.onmicrosoft.com` a member of role azure_ad_user. This must only be given to Azure AD users.
44-
45-
**Example:**
46-
47-
```sql
48-
CREATE ROLE "[email protected]" WITH LOGIN IN ROLE azure_ad_user;
49-
```
50-
51-
> [!NOTE]
52-
> Authenticating a user through Azure AD does not give the user any permissions to access objects within the Azure Database for PostgreSQL database. You must grant the user the required permissions manually.
53-
54-
## Creating Azure AD groups in Azure Database for PostgreSQL
55-
56-
To enable an Azure AD group for access to your database, use the same mechanism as for users, but instead specify the group name:
57-
58-
**Example:**
59-
60-
```sql
61-
CREATE ROLE "Prod DB Readonly" WITH LOGIN IN ROLE azure_ad_user;
62-
```
63-
64-
When logging in, members of the group will use their personal access tokens, but sign with the group name specified as the username.
65-
6638
## Connecting to Azure Database for PostgreSQL using Azure AD
6739

6840
The following high-level diagram summarizes the workflow of using Azure AD authentication with Azure Database for PostgreSQL:
@@ -163,6 +135,36 @@ psql "host=mydb.postgres... [email protected]@mydb dbname=postgre
163135

164136
You are now authenticated to your PostgreSQL server using Azure AD authentication.
165137

138+
## Creating Azure AD users in Azure Database for PostgreSQL
139+
140+
To add an Azure AD user to your Azure Database for PostgreSQL database, perform the following steps after connecting (see later section on how to connect):
141+
142+
1. First ensure that the Azure AD user `<user>@yourtenant.onmicrosoft.com` is a valid user in Azure AD tenant.
143+
2. Sign in to your Azure Database for PostgreSQL instance as the Azure AD Admin user.
144+
3. Create role `<user>@yourtenant.onmicrosoft.com` in Azure Database for PostgreSQL.
145+
4. Make `<user>@yourtenant.onmicrosoft.com` a member of role azure_ad_user. This must only be given to Azure AD users.
146+
147+
**Example:**
148+
149+
```sql
150+
CREATE ROLE "[email protected]" WITH LOGIN IN ROLE azure_ad_user;
151+
```
152+
153+
> [!NOTE]
154+
> Authenticating a user through Azure AD does not give the user any permissions to access objects within the Azure Database for PostgreSQL database. You must grant the user the required permissions manually.
155+
156+
## Creating Azure AD groups in Azure Database for PostgreSQL
157+
158+
To enable an Azure AD group for access to your database, use the same mechanism as for users, but instead specify the group name:
159+
160+
**Example:**
161+
162+
```sql
163+
CREATE ROLE "Prod DB Readonly" WITH LOGIN IN ROLE azure_ad_user;
164+
```
165+
166+
When logging in, members of the group will use their personal access tokens, but sign with the group name specified as the username.
167+
166168
## Token Validation
167169

168170
Azure AD authentication in Azure Database for PostgreSQL ensures that the user exists in the PostgreSQL server, and it checks the validity of the token by validating the contents of the token. The following token validation steps are performed:

0 commit comments

Comments
 (0)