Huawei Cloud Federated Authentication with Keycloak

举报
云小敏 发表于 2023/02/28 11:28:25 2023/02/28
【摘要】 1 Federated AuthenticationWith identity federation provided by Huawei Cloud Identity and Access Management (IAM), you do not need to create IAM users in Huawei Cloud for your workforce. Instead, th...

1 Federated Authentication

With identity federation provided by Huawei Cloud Identity and Access Management (IAM), you do not need to create IAM users in Huawei Cloud for your workforce. Instead, they can use their existing usernames and passwords to log in to Huawei Cloud. You can use identity provider (IdP) to assign permissions to your workforce.

Huawei Cloud supports federated identity authentication based on Web SSO and API calling. Here we use Keycloak as an enterprise IdP to describe the process of Web SSO–based federated identity authentication.

Prerequisites

You have registered an account in Huawei Cloud and the account is enabled.

Process Flow

The following figure shows the identity federation process between Keycloak and Huawei Cloud.

1.png

As shown in the preceding figure, the process of identity federation is as follows:

1.       A user enters the Huawei Cloud login link in the address bar of a browser to send a single sign-on (SSO) request to Huawei Cloud.

2.       Huawei Cloud searches for the IdP metadata file based on the login link and sends a SAML request to the browser.

3.       The browser responds and forwards the SAML request to Keycloak.

4.       The user enters their username and password on the Keycloak login page. Keycloak authenticates the user, constructs a SAML assertion containing the user information, and sends the assertion to the browser as a SAML response.

5.       The browser responds and forwards the SAML response to Huawei Cloud.

6.       Huawei Cloud parses the assertion in the SAML response, and issues a token to the user after identifying the group the user is mapped to according to the configured identity conversion rules.

7.       If the SSO is successful, the user can access Huawei Cloud based on the assigned permissions.


2 Configuring Huawei Cloud Information in Keycloak

Step 1     Save the assertion description of Huawei Cloud by entering the following URL in the address bar of the browser and saving the web page as a metadata.xml.

https://auth.huaweicloud.com/authui/saml/metadata.xml

2.png

Step 2     Log in to the Keycloak. In the navigation pane on the left, choose Clients and click Create.

3.png

Step 3     Click Select file, upload the Huawei Cloud metadata file, and then click Save.

Step 4     Disable Encrypt Assertions in settings.

4.png

Step 5     Click Save to save the settings.

5.png

Step 6     Click Mappers.

6.png

Step 7     On the displayed page, click Create.

Step 8     Create a username mapping.

7.png

Step 9     Create a user group mapping.

8.png

Step 10     Choose Users in the left navigation pane.

Step 11     Click Add User.

9.png

Step 12     On the Credentials tab, set a password for the user.

10.png

Step 13     Choose Groups in the left navigation pane.

Step 14     Click New to create a group.

11.png

Step 15     Choose Users in the left navigation pane.

12.png

Step 16     Locate the user and click Edit to go to the user details page.

13.png

Step 17     Click Groups and add the user to the admin group.

14.png

Step 18     Choose Realm Settings in the left navigation pane and save the Keycloak metadata file locally.

15.png

----End


3 Configuring an IdP in IAM

Step 1 Log in to the IAM console and choose Identity Providers in the left navigation pane.

Step 2 On the Identity Providers page, click Create Identity Provider.

16.png

Step 3 Set information about the IdP. For example, set the name to keycloak_idp_test.

17.png

Step 4 Click OK. The following message indicates that the IdP is created successfully.

18.png

Step 5 Locate the row containing the IdP and click Modify in the Operation

19.png

Step 6 Click Select File and select the downloaded Keycloak metadata file.

20.png

Step 7 Click Upload.

Step 8 In the Identity Conversion Rules area, click Edit Rule and copy the following to the edit box. This rule maps the usernames and their user groups in Keycloak to the usernames and belonging user groups in Huawei Cloud.

[ {   
    "remote": [     {       
        "type": "UserName"     
    },       {       
        "type": "Group"     
    }   ],
       "local": [     {       
        "user": {         
            "name": "{0}"       
        }     
    },       {       
        "group": {         
            "name": "{1}"       
        }     
    }   ] 
}]

21.png

Step 9 Click OK.

Step 10 Locate the IdP and click View in the Operation On the View Identity Provider Information page, copy the login link and open it in a browser.

22.png

Step 11 Enter your username and password in Keycloak to log in to Huawei Cloud. If you have logged in to Keycloak, you will be automatically redirected to Huawei Cloud.

----End

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。