|
| 1 | +--- |
| 2 | +id: adfs |
| 3 | +title: Add an ADFS as a SAML SSO provider in Ory |
| 4 | +sidebar_label: ADFS |
| 5 | +toc_max_heading_level: 4 |
| 6 | +--- |
| 7 | + |
| 8 | +# Active Directory Federation Services |
| 9 | + |
| 10 | +:::note |
| 11 | + |
| 12 | +To add an ADFS as a SAML SSO provider, you need a ADFS installed in a Windows Server. |
| 13 | + |
| 14 | +::: |
| 15 | + |
| 16 | +````mdx-code-block |
| 17 | +import Tabs from '@theme/Tabs'; |
| 18 | +import TabItem from '@theme/TabItem'; |
| 19 | +
|
| 20 | +<Tabs> |
| 21 | +<TabItem value="cli" label="Ory CLI"> |
| 22 | +
|
| 23 | +Follow these steps to add an ADFS as a SAML SSO provider to your project using the Ory CLI: |
| 24 | +
|
| 25 | +1. In the top bar of your Windows Server, click on **Tools** → **AD FS Management**. |
| 26 | +2. Click on **Relying Party Trusts**. |
| 27 | +3. Click on **Add Relying Party Trust...***. |
| 28 | +4. Select **Claims aware** then click on **Start**. |
| 29 | +5. Select **Import data about the relying party from a file** and select your Kratos SAML metadata file. |
| 30 | +6. Then click the **Next** button. |
| 31 | +7. Enter a display name for the relying party and click the **Next** button. |
| 32 | +8. Click **Next** in the Access Control window. |
| 33 | +9. Click **Next** again to proceed. |
| 34 | +10. Click the **Close** button in the last window. Your relying party trust is now added to your ADFS. |
| 35 | +11. Create a Jsonnet code snippet to map the desired claims to the Ory Identity schema. |
| 36 | +
|
| 37 | + ```jsonnet |
| 38 | + local claims = { |
| 39 | + email_verified: true, |
| 40 | + } + std.extVar('claims'); |
| 41 | +
|
| 42 | + { |
| 43 | + identity: { |
| 44 | + traits: { |
| 45 | + [if 'email' in claims && claims.email_verified then 'email' else null]: claims.email, |
| 46 | + first_name: claims.given_name, |
| 47 | + last_name: claims.family_name, |
| 48 | + [if 'hd' in claims && claims.email_verified then 'hd' else null]: claims.hd, |
| 49 | + }, |
| 50 | + }, |
| 51 | + } |
| 52 | + ``` |
| 53 | +
|
| 54 | + The sample Jsonnet snippet creates the following mapping: |
| 55 | +
|
| 56 | + | ADFS claim | Ory Identity schema mapping | |
| 57 | + | :----------- | :-------------------------- | |
| 58 | + | email | email | |
| 59 | + | given_name | first_name | |
| 60 | + | family_name | last_name | |
| 61 | +
|
| 62 | + :::note |
| 63 | +
|
| 64 | + If you want to use this data mapping, you must include the `first_name` and `last_name` fields in your Identity Schema |
| 65 | +
|
| 66 | + ::: |
| 67 | +
|
| 68 | +3. Encode the Jsonnet snippet with [Base64](https://www.base64encode.org/) or host it under an URL accessible to The Ory Network. |
| 69 | +
|
| 70 | + ```shell |
| 71 | + cat your-data-mapping.jsonnet | base64 |
| 72 | + ``` |
| 73 | +
|
| 74 | +4. Download the Ory Identities config from your project and save it to a file: |
| 75 | +
|
| 76 | + ```shell |
| 77 | + ## List all available projects |
| 78 | + ory list projects |
| 79 | +
|
| 80 | + ## Get config |
| 81 | + ory get identity-config {project-id} --format yaml > identity-config.yaml |
| 82 | + ``` |
| 83 | +
|
| 84 | +5. Add the SAML SSO provider configuration to the downloaded config. Add the Jsonnet snippet with mappings as a Base64 |
| 85 | + string or provide an URL to the file. |
| 86 | +
|
| 87 | + ```yaml |
| 88 | + selfservice: |
| 89 | + methods: |
| 90 | + saml: |
| 91 | + config: |
| 92 | + providers: |
| 93 | + - id: generic # This is `<provider-id>` in the Authorization callback URL. DO NOT CHANGE IT ONCE SET! |
| 94 | + label: generic # Used as a label for the UI login button |
| 95 | + provider: generic |
| 96 | + public_cert_path: .... # Replace this with the provider public certificate path |
| 97 | + private_key_path: .... # Replace this with the provider private key path |
| 98 | + mapper_url: "base64://{YOUR_BASE64_ENCODED_JSONNET_HERE}" |
| 99 | +
|
| 100 | + idp_information: |
| 101 | + idp_metadata_url: .... # Replace this with identity provider path URL |
| 102 | +
|
| 103 | + # You must match the values required by Kratos with the name of the attributes sent in the SAML assertion |
| 104 | + attributes_map: |
| 105 | + id: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn # ADFS example |
| 106 | + firstname: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname # ADFS example |
| 107 | + lastname: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname # ADFS example |
| 108 | + nickname: default |
| 109 | + gender: default |
| 110 | + birthdate: default |
| 111 | + picture: default |
| 112 | + email: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress # ADFS example |
| 113 | + roles: http://schemas.microsoft.com/ws/2008/06/identity/claims/role # ADFS example |
| 114 | + phone_number: default |
| 115 | + enabled: true |
| 116 | + ``` |
| 117 | +
|
| 118 | +6. Update the Ory Identities configuration using the file you worked with: |
| 119 | +
|
| 120 | + ```shell |
| 121 | + ory update identity-config {project-id} --file updated_config.yaml |
| 122 | + ``` |
| 123 | +
|
| 124 | +</TabItem> |
| 125 | +</Tabs> |
| 126 | +```` |
0 commit comments