Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Syntax of Identity Conversion Rules

Updated on 2023-03-07 GMT+08:00
An identity conversion rule is a JSON object which can be modified. The following is an example JSON object:
[
          {
                    "local": [
                              {
                                        "<user> or <group> or <groups>"
                              }
                    ],
                    "remote": [
                              {
                                        "<condition>"
                              }
                    ]
          }
]

Parameter description:

  • local: Identity information of a federated user mapped to IAM. The value of this field can contain placeholders, such as {0...n}. The attributes {0} and {1} represent the first and second remote attributes of the user information, respectively.
  • remote: Information about a federated user of the identity provider. This field is an expression consisting of assertion attributes and operators. The value of this field is determined by the assertion.
    • condition: Conditions for the identity conversion rule to take effect. The following three types of conditions are supported:
      • empty: The rule is matched to all claims containing the attribute type. This condition does not need to be specified. The condition result is the argument that is passed as input.
      • any_one_of: The rule is matched only if any of the specified strings appear in the attribute type. The condition result is Boolean, not the argument that is passed as input.
      • not_any_of: The rule is not matched if any of the specified strings appear in the attribute type. The condition result is Boolean, not the argument that is passed as input.
NOTICE:

The user information mapped to IAM can only contain letters, digits, spaces, hyphens (-), underscores (_), and periods (.), and cannot start with a digit.

Examples of the empty Condition

The empty condition returns character strings to replace the local attributes {0..n}.

  • In the following example, the username of a federated user will be "the value of the first remote attribute+space+the value of the second remote attribute" in IAM, that is, FirstName LastName. The group to which the user belongs is the value of the third remote attribute Group. This attribute has only one value.
    [ 
            { 
                "local": [ 
                    { 
                        "user": { 
                            "name": "{0} {1}" 
                        } 
                    }, 
                    { 
                        "group": { 
                            "name": "{2}" 
                        } 
                    } 
                ], 
                "remote": [ 
                    { 
                        "type": "FirstName" 
                    }, 
                    { 
                        "type": "LastName" 
                    }, 
                    { 
                        "type": "Group" 
                    } 
                ] 
            } 
    ]     

    If the following assertion (simplified for easy understanding) is received, the username of the federated user will be John Smith and the user will only belong to the admin group.

    {FirstName: John} 
    {LastName: Smith} 
    {Group: admin}
  • If a federated user will belong to multiple user groups in IAM, the identity conversion rule can be configured as follows:

    In the following example, the username of a federated user will be "the value of the first remote attribute+space+the value of the second remote attribute" in IAM, that is, FirstName LastName. The groups to which the user belongs are the value of the third remote attribute Groups.

    [  
            {  
                "local": [  
                    {  
                        "user": {  
                            "name": "{0} {1}"  
                        }  
                    },  
                    {  
                        "groups":  "{2}"  
                    }  
                ],  
                "remote": [  
                    {  
                        "type": "FirstName"  
                    },  
                    {  
                        "type": "LastName"  
                    },  
                    {  
                        "type": "Groups"  
                    }  
                ]  
            }  
    ]  

    If the following assertion is received, the username of the federated user will be John Smith and the user will belong to the admin and manager groups.

    {FirstName: John}  
    {LastName: Smith}  
    {Groups: [admin, manager]}

Examples of the "any one of" and "not any of" Conditions

Unlike the empty condition, the any one of and not any of conditions return Boolean values. These values will not be used to replace the local attributes. In the following example, only {0} will be replaced by the returned value of the first empty condition in the remote block. The value of group is fixed as admin.

  • The username of the federated user in IAM is the value of the first remote attribute, that is, UserName. The federated user belongs to the admin group. This rule takes effect only for users who are members of the idp_admin group in the identity provider.
    [ 
            { 
                "local": [ 
                    { 
                        "user": { 
                            "name": "{0}" 
                        } 
                    }, 
                    { 
                        "group": { 
                            "name": "admin" 
                        } 
                    } 
                ], 
                "remote": [ 
                    { 
                    "type": "UserName" 
                    }, 
                    { 
                        "type": "Groups", 
                        "any_one_of": [ 
                            "idp_admin" 
                        ] 
                    } 
                ] 
            } 
    ]     
  • If a federated user will belong to multiple user groups in IAM, the identity conversion rule can be configured as follows:
    The username of the federated user in IAM is the value of the first remote attribute, that is, UserName. The federated user belongs to the admin and manager groups. This rule takes effect only for users who are members of the idp_admin group in the identity provider.
    [  
            {  
                "local": [  
                    {  
                        "user": {  
                            "name": "{0}"  
                        }  
                    },  
                    {  
                        "groups": {
                               "name":"admin"
                        }
                    },
                    {  
                        "groups": {
                               "name":"manager"
                        }
                    }
                ],  
                "remote": [  
                    {  
                    "type": "UserName"  
                    },  
                    {  
                        "type": "Groups",  
                        "any_one_of": [  
                            "idp_admin"  
                        ]  
                    }  
                ]  
            }  
    ]     
    • The following assertion indicates that the federated user John Smith is a member of the idp_admin group. Therefore, the user can access the cloud platform.
      {UserName: John Smith} 
      {Groups: [idp_user, idp_admin, idp_agency]}
    • The following assertion indicates that the federated user John Smith is not a member of the idp_admin group. Therefore, the rule does not take effect for the user and the user cannot access the cloud platform.
      {UserName: John Smith} 
      {Groups: [idp_user, idp_agency]}

Example Condition Containing a Regular Expression

You can add "regex": true to a condition to calculate results using a regular expression.

This rule takes effect for any user whose username ends with @mail.com. The username of each applicable federated user is UserName in IAM and the user belongs to the admin group.
[ 
        { 
            "local": [ 
                { 
                    "user": { 
                        "name": "{0}" 
                    } 
                }, 
                { 
                    "group": { 
                        "name": "admin" 
                    } 
                } 
            ], 
            "remote": [ 
                { 
                "type": "UserName" 
                }, 
                { 
                    "type": "Groups", 
                    "any_one_of": [ 
                        ".*@mail.com$" 
                    ], 
                    "regex": true 
                } 
            ] 
        } 
]     

Examples of Combined Conditions

Multiple conditions can be combined using the logical operator AND.

This rule takes effect only for the federated users who do not belong to the idp_user or idp_agent user group in the identity provider. The username of each applicable federated user is UserName in IAM and the user belongs to the admin group.
[ 
        { 
            "local": [ 
                { 
                    "user": { 
                        "name": "{0}" 
                    } 
                }, 
                { 
                    "group": { 
                        "name": "admin" 
                    } 
                } 
            ], 
            "remote": [ 
                { 
                "type": "UserName" 
                }, 
                { 
                    "type": "Groups", 
                    "not_any_of": [ 
                        "idp_user" 
                    ] 
                }, 
                { 
                    "type": "Groups", 
                    "not_any_of": [ 
                        "idp_agent" 
                    ] 
                } 
            ] 
        } 
]     

The preceding rule is equivalent to the following:

[ 
        { 
            "local": [ 
                { 
                    "user": { 
                        "name": "{0}" 
                    } 
                }, 
                { 
                    "group": { 
                        "name": "admin" 
                    } 
                } 
            ], 
            "remote": [ 
                { 
                "type": "UserName" 
                }, 
                { 
                    "type": "Groups", 
                    "not_any_of": [ 
                        "idp_user", 
                        "idp_agent" 
                    ] 
                } 
            ] 
        } 
]     

Examples of Combined Rules

If multiple rules are combined, the methods for matching usernames and user groups are different.

The name of a federated user will be the username matched in the first rule that takes effect, and the user will belong to all groups matched in all rules that take effect. A federated user can log in only if at least one rule takes effect to match the username. For easy understanding, username and user group rules can be configured separately.

In the following example, the rules take effect for users in the idp_admin group. The username of each applicable federated user is UserName in IAM and the user belongs to the admin group.

[ 
    { 
        "local": [ 
            { 
                "user": { 
                    "name": "{0}" 
                } 
            } 
        ], 
        "remote": [ 
            { 
                "type": "UserName" 
            } 
        ] 
    }, 
    { 
        "local": [ 
            { 
                "group": { 
                    "name": "admin" 
                } 
            } 
        ], 
        "remote": [ 
            { 
                "type": "Groups", 
                "any_one_of": [ 
                    "idp_admin" 
                ] 
            } 
        ] 
    }
]

The following assertion indicates that user John Smith is a member of the idp_admin group in the identity provider and therefore meets the rules. The username of this user will be John Smith in IAM, and the user will belong to the admin group.

{UserName: John Smith} 
{Groups: [idp_user, idp_admin, idp_agency]}

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback