|
| 1 | +--- |
| 2 | +title: Set up sign-up and sign-in with a SwissID account |
| 3 | +titleSuffix: Azure AD B2C |
| 4 | +description: Provide sign-up and sign-in to customers with SwissID accounts in your applications using Azure Active Directory B2C. |
| 5 | +services: active-directory-b2c |
| 6 | +author: kengaderdus |
| 7 | +manager: celestedg |
| 8 | + |
| 9 | +ms.service: active-directory |
| 10 | +ms.workload: identity |
| 11 | +ms.topic: how-to |
| 12 | +ms.date: 12/07/2021 |
| 13 | +ms.author: kengaderdus |
| 14 | +ms.subservice: B2C |
| 15 | +zone_pivot_groups: b2c-policy-type |
| 16 | +--- |
| 17 | + |
| 18 | +# Set up sign-up and sign-in with a SwissID account using Azure Active Directory B2C |
| 19 | + |
| 20 | +[!INCLUDE [active-directory-b2c-choose-user-flow-or-custom-policy](../../includes/active-directory-b2c-choose-user-flow-or-custom-policy.md)] |
| 21 | + |
| 22 | +In this article, you learn how to provide sign-up and sign-in to customers with [SwissID](https://www.swissid.ch/) accounts in your applications using Azure Active Directory B2C (Azure AD B2C). You add the SwissID to your user flows or custom policy using OpenID Connect protocol. For more information, see [SwissID Integration Guidelines – OpenID Connect](https://www.swissid.ch/dam/jcr:471f63c6-606e-4c04-be02-afc99f4d2612). |
| 23 | + |
| 24 | +## Prerequisites |
| 25 | + |
| 26 | +[!INCLUDE [active-directory-b2c-customization-prerequisites](../../includes/active-directory-b2c-customization-prerequisites.md)] |
| 27 | + |
| 28 | +## Create a SwissID application |
| 29 | + |
| 30 | +To enable sign-in for users with a SwissID account in Azure AD B2C, you need to create an application. To create SwissID application, follow these steps: |
| 31 | + |
| 32 | +1. Contact [SwissID Business Partner support](https://www.swissid.ch/en/b2b-kontakt.html). |
| 33 | +1. After the sign up with SwissID, provide information about your Azure AD B2C tenant: |
| 34 | + |
| 35 | + |
| 36 | + |Key |Note | |
| 37 | + |---------|---------| |
| 38 | + |Redirect URI | Provide the `https://your-tenant-name.b2clogin.com/your-tenant-name.onmicrosoft.com/oauth2/authresp` URI. If you use a [custom domain](custom-domain.md), enter `https://your-domain-name/your-tenant-name.onmicrosoft.com/oauth2/authresp`. Replace `your-tenant-name` with the name of your tenant, and `your-domain-name` with your custom domain. | |
| 39 | + |Token endpoint authentication method| `client_secret_post`| |
| 40 | + |
| 41 | + |
| 42 | +1. After the app is registered, the following information will be provided by the SwissID. Use this information to configure your user flow, or custom policy. |
| 43 | + |
| 44 | + |
| 45 | + |Key |Note | |
| 46 | + |---------|---------| |
| 47 | + | Environment| The SwissID OpenId well-known configuration endpoint. For example, <https://login.sandbox.pre.swissid.ch/idp/oauth2/.well-known/openid-configuration>. | |
| 48 | + | Client ID | The SwissID client ID. For example, 11111111-2222-3333-4444-555555555555. | |
| 49 | + | Password| The SwissID client secret.| |
| 50 | + |
| 51 | + |
| 52 | +::: zone pivot="b2c-user-flow" |
| 53 | + |
| 54 | +## Configure SwissID as an identity provider |
| 55 | + |
| 56 | +1. Make sure you're using the directory that contains Azure AD B2C tenant. Select the **Directory + subscription** filter in the top menu and choose the directory that contains your Azure AD B2C tenant. |
| 57 | +1. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **Azure AD B2C**. |
| 58 | +1. Select **Identity providers**, and then select **New OpenID Connect provider**. |
| 59 | +1. Enter a **Name**. For example, enter *SwissID*. |
| 60 | +1. For **Metadata url**, enter the URL SwissID OpenId well-known configuration endpoint. For example: |
| 61 | + |
| 62 | + ```http |
| 63 | + https://login.sandbox.pre.swissid.ch/idp/oauth2/.well-known/openid-configuration |
| 64 | + ``` |
| 65 | +
|
| 66 | +1. For **Client ID**, enter the SwissID Client ID. |
| 67 | +1. For **Client secret**, enter the SwissID client secret. |
| 68 | +1. For the **Scope**, enter the `openid profile email`. |
| 69 | +1. Leave the default values for **Response type**, and **Response mode**. |
| 70 | +1. (Optional) For the **Domain hint**, enter `swissid.com`. For more information, see [Set up direct sign-in using Azure Active Directory B2C](direct-signin.md#redirect-sign-in-to-a-social-provider). |
| 71 | +1. Under **Identity provider claims mapping**, select the following claims: |
| 72 | +
|
| 73 | + - **User ID**: *sub* |
| 74 | + - **Given name**: *given_name* |
| 75 | + - **Surname**: *family_name* |
| 76 | + - **Email**: *email* |
| 77 | +
|
| 78 | +1. Select **Save**. |
| 79 | +
|
| 80 | +## Add SwissID identity provider to a user flow |
| 81 | +
|
| 82 | +At this point, the SwissID identity provider has been set up, but it's not yet available in any of the sign-in pages. To add the SwissID identity provider to a user flow: |
| 83 | +
|
| 84 | +1. In your Azure AD B2C tenant, select **User flows**. |
| 85 | +1. Click the user flow that you want to add the SwissID identity provider. |
| 86 | +1. Under the **Social identity providers**, select **SwissID**. |
| 87 | +1. Select **Save**. |
| 88 | +1. To test your policy, select **Run user flow**. |
| 89 | +1. For **Application**, select the web application named *testapp1* that you previously registered. The **Reply URL** should show `https://jwt.ms`. |
| 90 | +1. Select the **Run user flow** button. |
| 91 | +1. From the sign-up or sign-in page, select **SwissID** to sign in with SwissID account. |
| 92 | +
|
| 93 | +If the sign-in process is successful, your browser is redirected to `https://jwt.ms`, which displays the contents of the token returned by Azure AD B2C. |
| 94 | +
|
| 95 | +::: zone-end |
| 96 | +
|
| 97 | +::: zone pivot="b2c-custom-policy" |
| 98 | +
|
| 99 | +## Create a policy key |
| 100 | +
|
| 101 | +You need to store the client secret that you received from SwissID in your Azure AD B2C tenant. |
| 102 | +
|
| 103 | +1. Sign in to the [Azure portal](https://portal.azure.com/). |
| 104 | +2. Make sure you're using the directory that contains your Azure AD B2C tenant. Select the **Directory + subscription** filter in the top menu and choose the directory that contains your tenant. |
| 105 | +3. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **Azure AD B2C**. |
| 106 | +4. On the Overview page, select **Identity Experience Framework**. |
| 107 | +5. Select **Policy Keys** and then select **Add**. |
| 108 | +6. For **Options**, choose `Manual`. |
| 109 | +7. Enter a **Name** for the policy key. For example, `SwissIDSecret`. The prefix `B2C_1A_` is added automatically to the name of your key. |
| 110 | +8. In **Secret**, enter your SwissID client secret. |
| 111 | +9. For **Key usage**, select `Signature`. |
| 112 | +10. Click **Create**. |
| 113 | +
|
| 114 | +## Configure SwissID as an identity provider |
| 115 | +
|
| 116 | +To enable users to sign in using a SwissID account, you need to define the account as a claims provider that Azure AD B2C can communicate with through an endpoint. The endpoint provides a set of claims that are used by Azure AD B2C to verify that a specific user has authenticated. |
| 117 | +
|
| 118 | +You can define a SwissID account as a claims provider by adding it to the **ClaimsProviders** element in the extension file of your policy. |
| 119 | +
|
| 120 | +1. Open the *TrustFrameworkExtensions.xml*. |
| 121 | +2. Find the **ClaimsProviders** element. If it does not exist, add it under the root element. |
| 122 | +3. Add a new **ClaimsProvider** as follows: |
| 123 | +
|
| 124 | + ```xml |
| 125 | + <ClaimsProvider> |
| 126 | + <Domain>SwissID.com</Domain> |
| 127 | + <DisplayName>SwissID</DisplayName> |
| 128 | + <TechnicalProfiles> |
| 129 | + <TechnicalProfile Id="SwissID-OpenIdConnect"> |
| 130 | + <DisplayName>SwissID</DisplayName> |
| 131 | + <Protocol Name="OpenIdConnect" /> |
| 132 | + <Metadata> |
| 133 | + <Item Key="METADATA">https://login.sandbox.pre.swissid.ch/idp/oauth2/.well-known/openid-configuration</Item> |
| 134 | + <Item Key="client_id">Your Swiss client ID</Item> |
| 135 | + <Item Key="response_types">code</Item> |
| 136 | + <Item Key="scope">openid profile email</Item> |
| 137 | + <Item Key="response_mode">form_post</Item> |
| 138 | + <Item Key="HttpBinding">POST</Item> |
| 139 | + <Item Key="UsePolicyInRedirectUri">false</Item> |
| 140 | + </Metadata> |
| 141 | + <CryptographicKeys> |
| 142 | + <Key Id="client_secret" StorageReferenceId="B2C_1A_SwissIDSecret" /> |
| 143 | + </CryptographicKeys> |
| 144 | + <OutputClaims> |
| 145 | + <OutputClaim ClaimTypeReferenceId="issuerUserId" PartnerClaimType="sub" /> |
| 146 | + <OutputClaim ClaimTypeReferenceId="identityProvider" PartnerClaimType="iss" /> |
| 147 | + <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="socialIdpAuthentication" AlwaysUseDefaultValue="true" /> |
| 148 | + <OutputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="given_name" /> |
| 149 | + <OutputClaim ClaimTypeReferenceId="surName" PartnerClaimType="family_name" /> |
| 150 | + <OutputClaim ClaimTypeReferenceId="email" /> |
| 151 | + </OutputClaims> |
| 152 | + <OutputClaimsTransformations> |
| 153 | + <OutputClaimsTransformation ReferenceId="CreateRandomUPNUserName" /> |
| 154 | + <OutputClaimsTransformation ReferenceId="CreateUserPrincipalName" /> |
| 155 | + <OutputClaimsTransformation ReferenceId="CreateAlternativeSecurityId" /> |
| 156 | + <OutputClaimsTransformation ReferenceId="CreateSubjectClaimFromAlternativeSecurityId" /> |
| 157 | + <OutputClaimsTransformation ReferenceId="CreateDisplayName" /> |
| 158 | + </OutputClaimsTransformations> |
| 159 | + <UseTechnicalProfileForSessionManagement ReferenceId="SM-SocialLogin" /> |
| 160 | + </TechnicalProfile> |
| 161 | + </TechnicalProfiles> |
| 162 | + </ClaimsProvider> |
| 163 | + ``` |
| 164 | +
|
| 165 | +4. Set **client_id** to the SwissID client ID. |
| 166 | +5. Save the file. |
| 167 | +
|
| 168 | +[!INCLUDE [active-directory-b2c-add-identity-provider-to-user-journey](../../includes/active-directory-b2c-add-identity-provider-to-user-journey.md)] |
| 169 | +
|
| 170 | +
|
| 171 | +```xml |
| 172 | +<OrchestrationStep Order="1" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin"> |
| 173 | + <ClaimsProviderSelections> |
| 174 | + ... |
| 175 | + <ClaimsProviderSelection TargetClaimsExchangeId="SwissIDExchange" /> |
| 176 | + </ClaimsProviderSelections> |
| 177 | + ... |
| 178 | +</OrchestrationStep> |
| 179 | +
|
| 180 | +<OrchestrationStep Order="2" Type="ClaimsExchange"> |
| 181 | + ... |
| 182 | + <ClaimsExchanges> |
| 183 | + <ClaimsExchange Id="SwissIDExchange" TechnicalProfileReferenceId="SwissID-OpenIdConnect" /> |
| 184 | + </ClaimsExchanges> |
| 185 | +</OrchestrationStep> |
| 186 | +``` |
| 187 | + |
| 188 | +[!INCLUDE [active-directory-b2c-configure-relying-party-policy](../../includes/active-directory-b2c-configure-relying-party-policy-user-journey.md)] |
| 189 | + |
| 190 | +## Test your custom policy |
| 191 | + |
| 192 | +1. Select your relying party policy, for example `B2C_1A_signup_signin`. |
| 193 | +1. For **Application**, select a web application that you [previously registered](tutorial-register-applications.md). The **Reply URL** should show `https://jwt.ms`. |
| 194 | +1. Select the **Run now** button. |
| 195 | +1. From the sign-up or sign-in page, select **SwissID** to sign in with SwissID account. |
| 196 | + |
| 197 | +If the sign-in process is successful, your browser is redirected to `https://jwt.ms`, which displays the contents of the token returned by Azure AD B2C. |
| 198 | + |
| 199 | + |
| 200 | +::: zone-end |
| 201 | + |
| 202 | +## Move to production |
| 203 | + |
| 204 | +SwissID IdP provides Pre-production and Production environments. The configuration described in this article uses the pre-production environment. To use the production environment, follow these steps: |
| 205 | + |
| 206 | +1. Contact SwissId support for a production environment. |
| 207 | +1. Update your user flow or custom policy with the URI of the well-known configuration endpoint. |
| 208 | + |
| 209 | +## Next steps |
| 210 | + |
| 211 | +Learn how to [pass SwissID token to your application](idp-pass-through-user-flow.md). |
0 commit comments