Skip to content

Commit 9829236

Browse files
Merge pull request #278722 from craigshoemaker/swa/certificates
[Static Web Apps] Update: Custom authentication -> add Entra ID custom certificate
2 parents 9608e95 + 1bc41d1 commit 9829236

File tree

1 file changed

+53
-9
lines changed

1 file changed

+53
-9
lines changed

articles/static-web-apps/authentication-custom.md

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Azure Static Web Apps provides [managed authentication](authentication-authoriza
1515

1616
- Custom authentication also allows you to [configure custom providers](./authentication-custom.md?tabs=openid-connect#configure-a-custom-identity-provider) that support [OpenID Connect](https://openid.net/connect/). This configuration allows the registration of multiple external providers.
1717

18-
- Using any custom registrations disables all pre-configured providers.
18+
- Using any custom registrations disables all preconfigured providers.
1919

2020
> [!NOTE]
2121
> Custom authentication is only available in the Azure Static Web Apps Standard plan.
@@ -24,7 +24,7 @@ Azure Static Web Apps provides [managed authentication](authentication-authoriza
2424

2525
Custom identity providers are configured in the `auth` section of the [configuration file](configuration.md).
2626

27-
To avoid putting secrets in source control, the configuration looks into [application settings](application-settings.yml#configure-application-settings) for a matching name in the configuration file. You may also choose to store your secrets in [Azure Key Vault](./key-vault-secrets.md).
27+
To avoid putting secrets in source control, the configuration looks into [application settings](application-settings.yml#configure-application-settings) for a matching name in the configuration file. You might also choose to store your secrets in [Azure Key Vault](./key-vault-secrets.md).
2828

2929
# [Microsoft Entra ID](#tab/aad)
3030

@@ -91,6 +91,50 @@ To configure which accounts can sign in, see [Modify the accounts supported by a
9191
> [!NOTE]
9292
> While the configuration section for Microsoft Entra ID is `azureActiveDirectory`, the platform aliases this to `aad` in the URL's for login, logout and purging user information. Refer to the [authentication and authorization](authentication-authorization.yml) section for more information.
9393
94+
### Custom certificate
95+
96+
Use the following steps to add a custom certificate to your Microsoft Entra ID app registration.
97+
98+
1. If it isn't already, upload your certificate to a Microsoft Key Vault.
99+
100+
1. Add a managed identity on your Static Web App.
101+
102+
For user assigned managed identities, set `keyVaultReferenceIdentity` property on your static site object to the `resourceId` of the user assigned managed identity.
103+
104+
Skip this step if your managed identity is system assigned.
105+
106+
1. Grant the managed identity the following access policies:
107+
108+
- *Secrets*: **Get/List**
109+
- *Certificates*: **Get/List**
110+
111+
1. Update the auth config section of the `azureActiveDirectory` configuration section with a `clientSecretCertificateKeyVaultReference` value as shown in the following example:
112+
113+
```json
114+
{
115+
"auth": {
116+
"rolesSource": "/api/GetRoles",
117+
"identityProviders": {
118+
"azureActiveDirectory": {
119+
"userDetailsClaim": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress",
120+
"registration": {
121+
"openIdIssuer": "https://login.microsoftonline.com/common/v2.0",
122+
"clientIdSettingName": "AZURE_CLIENT_ID",
123+
"clientSecretCertificateKeyVaultReference": "@Microsoft.KeyVault(SecretUri=https://<KEY_VAULT_NAME>.azure.net/certificates/<CERTIFICATE_NAME>/<CERTIFICATE_VERSION_ID>)",
124+
"clientSecretCertificateThumbprint": "*"
125+
}
126+
}
127+
}
128+
}
129+
}
130+
```
131+
132+
Make sure to replace your values in for the placeholders surrounded by `<>`.
133+
134+
In the secret URI, specify the key vault name and certificate name. If you want to pin to a version, include the certificate version, otherwise omit the version to allow the runtime to select the newest version of the certificate.
135+
136+
Set `clientSecretCertificateThumbprint` equal to `*` to always pull the latest version of the certificates thumbprint.
137+
94138
# [Apple](#tab/apple)
95139

96140
To create the registration, begin by creating the following [application settings](application-settings.yml):
@@ -233,7 +277,7 @@ For more information on how to configure Twitter as an authentication provider,
233277

234278
# [OpenID Connect](#tab/openid-connect)
235279

236-
You can configure Azure Static Web Apps to use a custom authentication provider that adheres to the [OpenID Connect (OIDC) specification](https://openid.net/connect/). The following steps are required to use an custom OIDC provider.
280+
You can configure Azure Static Web Apps to use a custom authentication provider that adheres to the [OpenID Connect (OIDC) specification](https://openid.net/connect/). The following steps are required to use a custom OIDC provider.
237281

238282
- One or more OIDC providers are allowed.
239283
- Each provider must have a unique name in the configuration.
@@ -250,7 +294,7 @@ Once the application is registered with the identity provider, create the follow
250294
| `MY_PROVIDER_CLIENT_ID` | The client ID generated by the authentication provider for your static web app. |
251295
| `MY_PROVIDER_CLIENT_SECRET` | The client secret generated by the authentication provider's custom registration for your static web app. |
252296

253-
If you register additional providers, each one needs an associated client ID and client secret store in application settings.
297+
If you register other providers, each one needs an associated client ID and client secret store in application settings.
254298

255299
> [!IMPORTANT]
256300
> Application secrets are sensitive security credentials. Do not share this secret with anyone, distribute it within a client application, or check into source control.
@@ -290,7 +334,7 @@ Once you have the registration credentials, use the following steps to create a
290334

291335
- The provider name, `myProvider` in this example, is the unique identifier used by Azure Static Web Apps.
292336
- Make sure to replace `<PROVIDER_ISSUER_URL>` with the path to the _Issuer URL_ of the provider.
293-
- The `login` object allows you to provide values for: custom scopes, login parameters, or custom claims.
337+
- The `login` object allows you to provide values for: custom scopes, log in parameters, or custom claims.
294338

295339
---
296340

@@ -303,7 +347,7 @@ Identity providers require a redirect URL to complete the login or logout reques
303347
| Login | `https://<YOUR_SITE>/.auth/login/<PROVIDER_NAME_IN_CONFIG>/callback` |
304348
| Logout | `https://<YOUR_SITE>/.auth/logout/<PROVIDER_NAME_IN_CONFIG>/callback` |
305349

306-
If you are using Microsoft Entra ID, use `aad` as the value for the `<PROVIDER_NAME_IN_CONFIG>` placeholder.
350+
If you're using Microsoft Entra ID, use `aad` as the value for the `<PROVIDER_NAME_IN_CONFIG>` placeholder.
307351

308352
> [!Note]
309353
> These URLs are provided by Azure Static Web Apps to receive the response from the authentication provider, you don't need to create pages at these routes.
@@ -319,7 +363,7 @@ To use a custom identity provider, use the following URL patterns.
319363
| User details | `/.auth/me` |
320364
| Purge user details | `/.auth/purge/<PROVIDER_NAME_IN_CONFIG>` |
321365

322-
If you are using Microsoft Entra ID, use `aad` as the value for the `<PROVIDER_NAME_IN_CONFIG>` placeholder.
366+
If you're using Microsoft Entra ID, use `aad` as the value for the `<PROVIDER_NAME_IN_CONFIG>` placeholder.
323367

324368
## Manage roles
325369

@@ -350,7 +394,7 @@ Invitations are specific to individual authorization-providers, so consider the
350394
| GitHub | username |
351395
| Twitter | username |
352396

353-
Do the following steps to create an invitation.
397+
Use the following steps to create an invitation.
354398

355399
1. Go to a Static Web Apps resource in the [Azure portal](https://portal.azure.com).
356400
2. Under _Settings_, select **Role Management**.
@@ -391,7 +435,7 @@ When the user selects the link in the invitation, they're prompted to sign in wi
391435
As you remove a user, keep in mind the following items:
392436

393437
- Removing a user invalidates their permissions.
394-
- Worldwide propagation may take a few minutes.
438+
- Worldwide propagation might take a few minutes.
395439
- If the user is added back to the app, the [`userId` changes](user-information.md).
396440

397441
# [Function (preview)](#tab/function)

0 commit comments

Comments
 (0)