简体   繁体   English

WSO2is SCIM 2 使用自定义字段创建新用户

[英]WSO2is SCIM 2 create new user with custom fields

I can create new users following a sample found it here:我可以按照在此处找到的示例创建新用户:

curl -v -k --user admin@tenant1.com@tenant1.com:admin --data '{"schemas":[],"name":{"familyName":"jackson","givenName":"kim"},"phoneNumbers":[{"type":"mobile","value":"9999"}],"addresses":[{"type":"work","streetAddress":"100 Universal City Plaza","locality":"Hollywood","region":"CA","postalCode":"90068","country":"USA","formatted":"100 Universal City Plaza\nHollywood, CA 90068 USA","primary":true},{"type":"home","streetAddress":"456 Hollywood Blvd","locality":"Hollywood","region":"CA","postalCode":"91608","country":"USA","formatted":"456 Hollywood Blvd\nHollywood, CA 91608 USA"}],"userName":"kim@mail.com","password":"kimwso2","nickName":"abc","title":"Operations Chief","urn:ietf:params:scim:schemas:core:2.0:User:streetAddress":"Miami, florida","emails":[{"primary":true,"value":"kim.jackson@gmail.com","type":"home"},{"value":"kim_j@wso2.com","type":"work"}]}' --header "Content-Type:application/json" https://localhost:9443/t/tenant1.com/scim2/Users

I want to add support for departments field to a new user.我想向新用户添加对departments字段的支持。

In claims for urn:ietf:params:scim:schemas:extension:enterprise:2.0:User I have made sure that the claim department exists with the mapping to http://wso2.org/claimsurn:ietf:params:scim:schemas:extension:enterprise:2.0:User的索赔中,我确保索赔部门存在并映射到http://wso2.org/claims

在此处输入图像描述

在此处输入图像描述

script with department added添加部门的脚本

curl -v -k --user admin@tenant1.com@tenant1.com:admin --data '{"schemas":[],"name":{"familyName":"jackson","givenName":"kim"},"phoneNumbers":[{"type":"mobile","value":"9999"}],"addresses":[{"type":"work","streetAddress":"100 Universal City Plaza","locality":"Hollywood","region":"CA","postalCode":"90068","country":"USA","formatted":"100 Universal City Plaza\nHollywood, CA 90068 USA","primary":true},{"type":"home","streetAddress":"456 Hollywood Blvd","locality":"Hollywood","region":"CA","postalCode":"91608","country":"USA","formatted":"456 Hollywood Blvd\nHollywood, CA 91608 USA"}],"department":["Accounting","Marketing and Advertising"],"userName":"kim@mail.com","password":"kimwso2","nickName":"abc","title":"bhhhxxs","urn:ietf:params:scim:schemas:core:2.0:User:streetAddress":"bhhhxxs","emails":[{"primary":true,"value":"kim.jackson@gmail.com","type":"home"},{"value":"kim_j@wso2.com","type":"work"}]}' --header "Content-Type:application/json" https://localhost:9443/t/tenant1.com/scim2/Users

If I add department field to script, this create but not return when make the request for this user id:如果我将部门字段添加到脚本,则在请求此用户 ID 时创建但不返回:

result of curl -v -k --user admin@tenant1.com@tenant1.com:admin https://localhost:9443/t/tenant1.com/scim2/Users/44c7b532-09fe-4530-a199-cf81bff95b3a | jq. result of curl -v -k --user admin@tenant1.com@tenant1.com:admin https://localhost:9443/t/tenant1.com/scim2/Users/44c7b532-09fe-4530-a199-cf81bff95b3a | jq. curl -v -k --user admin@tenant1.com@tenant1.com:admin https://localhost:9443/t/tenant1.com/scim2/Users/44c7b532-09fe-4530-a199-cf81bff95b3a | jq.

{
    "emails": [{
            "type": "work",
            "value": "kim_j@wso2.com"
        },
        {
            "type": "home",
            "value": "kim.jackson@gmail.com"
        }
    ],
    "addresses": [{
            "type": "work",
            "value": "100 Universal City Plaza\nHollywood, CA 90068 USA"
        },
        {
            "type": "home",
            "value": "456 Hollywood Blvd\nHollywood, CA 91608 USA"
        }
    ],
    "meta": {
        "created": "2020-04-08T12:46:30.549Z",
        "location": "https://localhost:9443/t/tenant1.com/scim2/Users/44c7b532-09fe-4530-a199-cf81bff95b3a",
        "lastModified": "2020-04-08T12:46:30.549Z",
        "resourceType": "User"
    },
    "nickName": "abc",
    "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:User",
        "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
    ],
    "roles": [{
        "type": "default",
        "value": "Internal/everyone"
    }],
    "name": {
        "givenName": "kim",
        "familyName": "jackson"
    },
    "id": "44c7b532-09fe-4530-a199-cf81bff95b3a",
    "userName": "kim@mail.com",
    "title": "bhhhxxs",
    "phoneNumbers": [{
        "type": "mobile",
        "value": "9999"
    }]
}

I already read this docs without success: https://is.docs.wso2.com/en/latest/develop/extensible-scim-user-schemas-with-wso2-identity-server/#extensible-scim-user-schemas-with-wso2-identity-server我已经阅读了这个文档但没有成功: https://is.docs.wso2.com/en/latest/develop/extensible-scim-user-schemas-with-wso2-identity-server/#extensible-scim-user-schemas-with-wso2-identity-server

https://is.docs.wso2.com/en/latest/develop/extending-scim2-user-schemas/#extending-the-scim-20-api

My setup: wso2is 5.10我的设置:wso2is 5.10

You can find a sample request to create a user with an extended schema attribute in https://github.com/wso2/docs-is/issues/1556您可以在https://github.com/wso2/docs-is/issues/1556中找到创建具有扩展架构属性的用户的示例请求

The trick is to represent the extended attribute as below in the create request诀窍是在创建请求中表示如下扩展属性

"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
    "department": [
        "Accounting",
        "Marketing and Advertising"
    ]
}

Update: By default the urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:department is not a multi-valued attribute in the scim2 schema defined in the server.更新:默认情况下,urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:department 不是服务器中定义的 scim2 模式中的多值属性。 You can make it multi valued by editing the IS_HOME/repository/conf/scim2-schema-extension.config file to make it a multi-valued attribute您可以通过编辑 IS_HOME/repository/conf/scim2-schema-extension.config 文件使其成为多值属性,使其成为多值属性

{
"attributeURI":"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:department",
"attributeName":"department",
"dataType":"string",
"multiValued":"true",
"description":"Identifies the name of a department",
"required":"false",
"caseExact":"false",
"mutability":"readWrite",
"returned":"default",
"uniqueness":"none",
"subAttributes":"null",
"canonicalValues":[],
"referenceTypes":[]
}

Note how the "multiValue" attribute has been updated.请注意“multiValue”属性是如何更新的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM