Skip to content

Commit f401dc7

Browse files
committed
updates
1 parent 666ba7d commit f401dc7

10 files changed

+95
-15
lines changed
152 KB
Loading
170 KB
Loading
157 KB
Loading
3.34 KB
Loading
149 KB
Loading
157 KB
Loading
152 KB
Loading
165 KB
Loading
169 KB
Loading

src/pages/[platform]/build-a-backend/auth/examples/microsoft-entra-id-saml/index.mdx

Lines changed: 95 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ export function getStaticProps() {
2828
};
2929
}
3030

31-
Microsoft Entra ID can be configured as a SAML provider for use with Amazon Cognito.
31+
{/* add important things to know */}
32+
{/* SAML redirect URIs (including logout and limitation with upstream signout) */}
33+
{/* how to set attribute mapping with soap namespace */}
3234

33-
<Callout warning>
34-
35-
**Warning:** there is a known limitation where upstream sign-out functionality successfully signs out of Entra ID, but fails to redirect back to the user app.
35+
Microsoft Entra ID can be configured as a SAML provider for use with Amazon Cognito. Integrating Entra ID enables you to sign in with your existing enterprise users, and maintain profiles unique to the Amplify Auth resource for use within your Amplify app. To learn more, visit the [Azure documentation for SAML authentication with Microsoft Entra ID](https://learn.microsoft.com/en-us/entra/architecture/auth-saml).
3636

37-
</Callout>
37+
## Start your personal cloud sandbox
3838

3939
To get started, define your Amplify Auth resource with the appropriate redirect URIs:
4040

@@ -107,32 +107,63 @@ Deploy to your personal cloud sandbox with `npx ampx sandbox`. This will generat
107107
}
108108
```
109109

110+
## Set up Microsoft Entra ID
111+
112+
{/* @todo migrate to use sample Entra ID SAML Toolkit??? */}
113+
110114
Next, navigate to [portal.amazon.com](https://portal.azure.com/), select **Entra ID**. In your default directory, or company's existing directory, under **Manage**, select **Enterprise Applications**
111115

112-
{/* @TODO update screenshot for enterprise apps */}
113-
![Azure portal highlighting App Registrations and New registration in Entra ID](/images/auth/examples/microsoft-entra-id-saml/entra-id-new-registration.png)
116+
![Entra ID default directory page highlighting Enterprise Applications](/images/auth/examples/microsoft-entra-id-saml/entra-id-select-enterprise-applications.png)
117+
118+
Afterwards, select **New application**, then select **Create your own application**. Specify a name for the application and choose **Integrate any other application you don't find in the gallery (Non-gallery)**
119+
120+
![Azure portal creating a new enterprise application for Entra ID](/images/auth/examples/microsoft-entra-id-saml/entra-id-new-enterprise-application.png)
121+
122+
Now that you have created the new enterprise application you can begin to configure Single Sign-on with SAML. Select **Single sign-on**
123+
124+
![Entra ID enterprise application highlighting "single sign-on"](/images/auth/examples/microsoft-entra-id-saml/entra-id-select-single-sign-on.png)
125+
126+
Then select **SAML**
127+
128+
![Entra ID enterprise application single sign-on setup highlighting "SAML"](/images/auth/examples/microsoft-entra-id-saml/entra-id-select-saml.png)
114129

115-
Afterwards, select **New application**, then select **Create your own application**. Specify a name for the application and choose **Register an application to integrate with Entra ID (App you're developing)**
130+
You will be directed to a page to set up single sign-on with SAML, which needs a few pieces of information from your Amplify Auth resource.
116131

117-
![Azure portal highlighting App Registrations and New registration in Entra ID](/images/auth/examples/microsoft-entra-id-saml/entra-id-new-enterprise-application.png)
132+
![Entra ID set up single sign-on page with a form requiring an entity ID and reply URL](/images/auth/examples/microsoft-entra-id-saml/entra-id-set-up-saml.png)
118133

119-
Select **Complete**. After being redirected to the **Register an application** form, specify a name for your Entra ID App -- this is the name of the app that will integrate with Amazon Cognito (e.g. `amplify-gen2-saml-with-entra-id`). Using the domain copied from the generated `amplify_outputs.json` file, specify a **Redirect URI (Optional)** as a **Web** redirect
134+
In the **Basic SAML Configuration** step, select **Edit** and populate with the appropriate values.
135+
136+
| Label | Value |
137+
|-------|-------|
138+
| Identifier (Entity ID) | `urn:amazon:cognito:sp:<your-cognito-user-pool-id>` |
139+
| Reply URL (Assertion Consumer Service URL) | `https://<your-cognito-domain>/saml2/idpresponse` |
140+
| Logout Url (Optional) | `https://<your-cognito-domain>/saml2/logout` |
120141

121142
<Callout info>
122143

123-
**Note:** redirect URIs for SAML providers follow the convention:
144+
**Note:** Amazon Cognito redirect URIs for SAML providers follow the convention:
124145

125146
```text showLineNumbers={false}
126-
https://<some-hash>.auth.<aws-region>.amazoncognito.com/saml2/idpresponse
147+
https://<some-hash>.auth.<aws-region>.amazoncognito.com/saml2/<action>
127148
```
128149

129-
[Learn more about configuring Amazon Cognito with SAML identity providers](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-saml-idp.html)
150+
If you are using a custom domain the route remains the same: `/saml2/<action>`. [Learn more about configuring Amazon Cognito with SAML identity providers](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-saml-idp.html)
151+
152+
</Callout>
153+
154+
<Callout warning>
155+
156+
**Warning:** there is a known limitation where upstream sign-out functionality successfully signs out of Entra ID, but fails to redirect back to the user app. This behavior is disabled by default with SAML integrations in Amplify Auth.
130157

131158
</Callout>
132159

133-
![Entra ID app registration form with redirect URI specified](/images/auth/examples/microsoft-entra-id-saml/entra-id-register-an-app-redirect-uri.png)
160+
Save the configuration and proceed to Step 3's **SAML Certificates** section. Copy the **App Federation Metadata Url**
161+
162+
![Entra ID set up single sign-on page highlighting the app federation metadata URL](/images/auth/examples/microsoft-entra-id-saml/entra-id-copy-federation-url.png)
163+
164+
## Configure Amplify Auth with Entra ID
134165

135-
Complete the Entra ID App registration by selecting **Register**.
166+
Now that you've configured your SAML provider with Microsoft Entra ID and copied the **App Federation Metadata Url**, configure your Amplify Auth resource with the new SAML provider and paste the URL value into the `metadataContent` property:
136167

137168
```ts title="amplify/auth/resource.ts"
138169
import { defineAuth } from "@aws-amplify/backend"
@@ -161,3 +192,52 @@ export const auth = defineAuth({
161192
},
162193
})
163194
```
195+
196+
User attributes can be found in Step 2's **Attributes & Claims** section, and are prefixed with a namespace by default. The example above shows mapping the default claim for the SAML user's email address, however additional attributes can be mapped.
197+
198+
## Optionally upload the Cognito Signing Certificate
199+
200+
In the AWS Console, navigate to your Cognito User Pool. Select the identity provider, **MicrosoftEntraIDSAML**, created after configuring Amplify Auth with the Entra ID SAML provider. Select **View signing certificate** and **download as .crt**
201+
202+
![Amazon Cognito console highlighting "view signing certificate" for SAML provider](/images/auth/examples/microsoft-entra-id-saml/cognito-view-signing-certificate.png)
203+
204+
Rename the file extension to `.cer` in order to upload to Azure. On the **Single sign-on** page, scroll down to **Step 3** (**SAML Certificates**), and under **Verification Certificates (optional)**, select **Edit**.
205+
206+
![Entra ID single sign-on page highlighting "edit" for verification certificates](/images/auth/examples/microsoft-entra-id-saml/entra-id-edit-verification-certificate.png)
207+
208+
Select **Require verification certificates** and upload the certificate.
209+
210+
![Entra ID verification certificate upload pane](/images/auth/examples/microsoft-entra-id-saml/entra-id-upload-verification-certificate.png)
211+
212+
Save your changes, and now requests to Entra ID from your Cognito User Pool will be verified.
213+
214+
## Connect your frontend
215+
216+
Now you're users are ready to sign in with Microsoft Entra ID. To sign in with this custom provider, specify the provider name as the name specified in your Amplify Auth definition: `MicrosoftEntraIDSAML`
217+
218+
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "react-native", "vue"]}>
219+
220+
```ts title="main.ts"
221+
import { signInWithRedirect } from "aws-amplify/auth"
222+
223+
signInWithRedirect({
224+
provider: { custom: "MicrosoftEntraIDSAML" }
225+
})
226+
```
227+
228+
</InlineFilter>
229+
<InlineFilter filters={["android"]}>
230+
231+
{/* @todo */}
232+
233+
</InlineFilter>
234+
<InlineFilter filters={["flutter"]}>
235+
236+
{/* @todo */}
237+
238+
</InlineFilter>
239+
<InlineFilter filters={["swift"]}>
240+
241+
{/* @todo */}
242+
243+
</InlineFilter>

0 commit comments

Comments
 (0)