首页 > 解决方案 > WSO2 IS 5.9.0 更新用户声明

问题描述

我有两个问题,当使用setUserClaimValue来自RemoteUserStoreManagerServiceSOAP 端点的方法时,更新效果很好。

但是,端点/userinfo丢失了值,我需要重新验证用户以生成新的访问令牌,并且一切正常。

我需要使用setUserClaimValue来自RemoteUserStoreManagerService更新多个声明的方法,但什么也没发生,我没有任何错误,但声明没有更新。

这是我的环境:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.ws.um.carbon.wso2.org" xmlns:xsd="http://common.mgt.user.carbon.wso2.org/xsd">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:setUserClaimValues>
         <!--Optional:-->
         <ser:userName>username@mail.com</ser:userName>
         <!--Zero or more repetitions:-->
         <ser:claims>
            <!--Optional:-->
            <xsd:claimURI>http://wso2.org/claims/emailaddress</xsd:claimURI>
            <!--Optional:-->
            <xsd:value>newemail@mail.com</xsd:value>
         </ser:claims>
         <!--Optional:-->
         <ser:profileName></ser:profileName>
      </ser:setUserClaimValues>
   </soapenv:Body>
</soapenv:Envelope>

我应该使用什么方法来更新多个索赔?为什么更新声明时,我的实际访问令牌从 /userinfo 端点丢失了数据,是否有必要生成新的访问令牌?

标签: wso2wso2is

解决方案


1)

我应该使用什么方法来更新多个索赔?

你必须使用setUserClaimValuesfrom RemoteUserStoreManagerService。您可以关注此文档以获取更多信息RemoteUserStoreManagerService

下面给出了一个示例肥皂服务。

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://service.ws.um.carbon.wso2.org" xmlns:xsd="http://common.mgt.user.carbon.wso2.org/xsd">
   <soap:Header/>
   <soap:Body>
      <ser:setUserClaimValues>
         <ser:userName>piraveena</ser:userName>
         <ser:claims>
            <xsd:claimURI>http://wso2.org/claims/organization</xsd:claimURI>
            <xsd:value>wso2</xsd:value>
         </ser:claims>
         <ser:claims>
            <xsd:claimURI>http://wso2.org/claims/country</xsd:claimURI>
            <xsd:value>srilanka</xsd:value>
         </ser:claims>
         <ser:profileName>default</ser:profileName>
      </ser:setUserClaimValues>
   </soap:Body>
</soap:Envelope>

2)

为什么更新声明时,我的实际访问令牌从 /userinfo 端点丢失了数据?

我无法在本地重现此问题。即使在通过管理服务更新声明后,我也能够在不重新验证的情况下获得用户声明。

当用户声明更新时,映射到访问令牌的用户属性缓存也将被事件清除。所以下次调用 useinfo 端点时,缓存将为空。在这种情况下,将从用户存储中获取声明。请在此处参考此代码。因此,用户不需要重新认证,因为用户属性存在于用户存储中。

但是当您启用电子邮件作为用户名并通过服务更新用户的电子邮件时,您可能会遇到此问题。


推荐阅读