Here I'm covering how to configure WSO2 API Manager 4.1.0 federated authentication with Azure Active Directory step by step(OpenID connect SSO flow)
1. Azure configuration.
1.1 Azure App Registration.
First login to your Azure portal with your credentials. If you don't have an account you can create a free trial account to check this scenario.
Once you successfully logged-in you can see as below.
Click on the Azure Active Directory and select which AD you want to use. If you don't have created AD then you can create a new one for this by clicking on the Create Directory icon. Enter the required details and create new one. It will take few minuted to create an AD for you.
Once all done with new creation select the Azure AD and select App registration on the left navigation panel to register an Open ID client.
Click on the New registration and enter the following details:- Name: wso2-apim (any desired name as you want)
- Supported Account Types: Accounts in this organizational directory only
- Redirect URI: Web , https://<hostname>:9443/commonauth (change the hostname according to your environment)
And click on Register.
After successful creation you will be redirected to a general info page of the registered application. On this page copy and save the Application (client) ID as it will need for API Manager configurations.
Then click on the Certificates & secrets section in the left side panel and select the New client secret to generate a secret for our newly created wso2-apim application.
Enter the following details and click Add.
- Description: WSO2APIMDEV OIDC Secret (You can change this as per your choice)
- Expires: Select your desired time period
After that click on the API permissions in the left navigation panel to configure the OpenID and Profile scope permissions to your application.
Click on the Add a permission button to add new permissions. Once you click, you will see a side window popped up with the following options.
Choose the Microsoft Graph option and select Delegated permissions on the following screen. Then select the following permissions.
- openid
- Profile
1.2 Group Registration.
- Group type: Security
- Group name: Subscriber
- Group description: Group for subscriber
1.2.1 Add Groups claim.
2. WSO2 API Manager configuration.
2.1 Identity Provider Creation.
Go to the Carbon Management console, and log-in with the admin credentials.
Select the Add under the Identity Providers and input the followings:
- Identity Provide Name: AzureADIDP
- Display Name: Azure AD IDP
- Choose IDP Certificate Type: Use IDP JWKS Endpoint
- Identity Provider’s JWKS Endpoint: the JWKS URI found in the OpenID Connect metadata document
Next, expand the Claim Configurations > Basic Claim configuration > Define Custom Claim Dialect > Add Claim Mapping and add the following mappings
- preferred_username : http://wso2.org/claims/displayName
- roles : http://wso2.org/claims/role
- User ID Claim URI: preferred_username
- Role Claim URI: roles
Expand the Role configurations and click on the Add Role Mapping. Paste the Object ID acquired from the Subscriber group in the Azure service and map it with our internal subscriber role
- The Object ID of Subscriber Group : Internal/subscriber
Given below is a sample Role mapping configuration.
Then, expand the Federated Authenticators > OAuth2/OpenID Connect Configurations and perform the following
- Enable OAuth2 / OpenID Connect: true
- Default: true
- Client ID: the Client ID of our WSO2APIM Azure app
- Client Secret: the generated secret of our WSO2APIM Azure app
- Authorization Endpoint URL: the authorization_endpoint in the OpenID Connect metadata document
- Token Endpoint URL: the token_endpoint in the OpenID Connect metadata document
- Userinfo Endpoint URL: the userinfo_endpoint in the OpenID Connect metadata document
- Additional Query Parameters: scope=openid profile email
And finally, expand the Just-In-Time Provisioning accordion and configure as follows.
2.2 Service Provider Creation.
From API Manager 4.x onwards, both Publisher and Devportal nodes are configured with OIDC SSO flows as default.
Hence, go to both Publisher and Devportal nodes and click on the Sign-in button to automatically create and register a Service Provider for the OIDC SSO flow. You don't have to log-in to the portals, the above-mentioned process is to create the respective Service Providers in the API Manager.
Navigate to the Carbon Management console and sign-in with the Admin credentials.
Click on List under Service Providers section to list the automatically created Service Providers respective to Publisher: apim_publisher and Devportal: apim_devportal.
Click the Edit of the apim_devportal and expand the Claim Configurations. Select "Define Custom Claim Dialect" and make the following changes
- preferred_username : http://wso2.org/claims/displayName : Requested
Next, expand the Local & Outbound Authentication Configuration and select the AzureADIDP as the Federated Authentication and make the following changes
Do the same configurations for apim_publisher.
Now we are done with all configs. We have now successfully configured OpenID Connect Federated Authentication between Azure AD and Single Sign-On with OpenID Connect with APIM Devportal and Publisher.
Go to the Publisher or devporal and click on Sign-In. You will be redirected to the Microsoft’s login page to enter the credentials. Enter the credentials of our Microsoft User and then allow the attributes on the consent screen to continue with the federation and provision of the users to the WSO2
No comments:
Post a Comment