WSO2 身份服务器电子邮件或伪作为用户名 [英] WSO2 identity server email or pseudo as username

查看:16
本文介绍了WSO2 身份服务器电子邮件或伪作为用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与 WSO2 身份服务器电子邮件作为用户名 完全相同但我们希望同时选择提供用户名作为电子邮件地址或用户名(不带 @ 的伪名).

我了解使用 @ 的租户完全限定名称的问题,但我们不能更改完全限定租户的 @ 字符吗?

是否可以同时使用电子邮件地址或用户名作为用户名,如果可以,您能否提供配置,我无法按照 https://docs.wso2.com/display/IS520/Using+Email+Address+as+the+Username>

我编辑了我的问题以测试 Rajjaz Mohammed 和 Pradeepa Wickramasinghe 的答案:

我评论了当我添加一个没有 @ 的用户时,我得到:<代码>引起:org.wso2.carbon.user.core.UserStoreException:用户名 jacques.martin 无效.用户名必须是非空字符串,格式如下:^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$在 org.wso2.carbon.user.core.common.AbstractUserStoreManager.addUser(AbstractUserStoreManager.java:1405)

如果我删除此标签 我收到以下错误:

<代码>TID: [1] [] [2016-11-22 13:16:50,409] admin@test.com@mytenant.com [1] [IS]ERROR {org.wso2.carbon.identity.mgt.util.Utils}- 无法检索用户的声明:jacques.martin@mytenant.comorg.wso2.carbon.user.core.UserStoreException:UserNotFound:用户 jacques.martin@mytenant.com 不存在于:PRIMARY在 org.wso2.carbon.user.core.common.AbstractUserStoreManager.callSecure(AbstractUserStoreManager.java:168)在 org.wso2.carbon.user.core.common.AbstractUserStoreManager.getUserClaimValues(AbstractUserStoreManager.java:697)在 org.wso2.carbon.identity.mgt.util.Utils.getClaimFromUserStoreManager(Utils.java:189)在 org.wso2.carbon.identity.mgt.util.Utils.getEmailAddressForUser(Utils.java:226)在 org.wso2.carbon.identity.mgt.mail.AbstractEmailSendingModule.getNotificationAddress(AbstractEmailSendingModule.java:53)在 org.wso2.carbon.identity.mgt.RecoveryProcessor.notifyWithEmail(RecoveryProcessor.java:541)在 org.wso2.carbon.identity.mgt.services.UserInformationRecoveryService.registerUser(UserInformationRecoveryService.java:890)Pradeepa Wickramasinghe 的回答也有同样的错误.

我的java代码如下:<代码>userInformationRecoveryClient.registerUser(user.getUsername(), user.getPassword(), claim, "default", tenant );在声明中,我已正确设置 http://wwso2.org/claims/email

解决方案

是的,是否可以将用户名用作 电子邮件用户名.为此,您需要按照以下步骤操作,

  1. 在 [IS_HOME]/repository/conf/carbon.xml 文件中通过取消注释启用电子邮件用户名,如下所示,

true

  1. 将新属性添加到 [IS_HOME]/repository/conf/user-mgt.xml 文件中,如下所示,

[a-zA-Z0-9@._-|//]{3,30}$

  1. 将 [IS_HOME]/repository/conf/user-mgt.xml 文件中的UsernameJavaRegEx"和UsernameJavaScriptRegEx"更改如下,

[a-zA-Z0-9@._-|//]{3,30}$

[a-zA-Z0-9._-|//]{3,30}$</Property>

您可以在此处找到更多详细信息.

This is quite the same question as WSO2 identity server email as username but we want to have both choice to provide username as email address or user's name (pseudo without @).

I understand the problem with the tenant fully qualified name using @ but can't we change the @ character for the tenant fully qualified ?

Is it possible to use both email address or user's name as username and if so can you provide the configuration, I cannot make it work following https://docs.wso2.com/display/IS520/Using+Email+Address+as+the+Username

I edited my question to test both Rajjaz Mohammed and Pradeepa Wickramasinghe answers :

I commented <Property name="UsernameJavascriptRegEx"> When I add a user without @ I get : Caused by: org.wso2.carbon.user.core.UserStoreException: Username jacques.martin is not valid. User name must be a non null string with following format, ^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ at org.wso2.carbon.user.core.common.AbstractUserStoreManager.addUser(AbstractUserStoreManager.java:1405)

If I remove this tag <Property name="UsernameJavaRegEx"> I get the following error :

TID: [1] [] [2016-11-22 13:16:50,409] admin@test.com@mytenant.com [1] [IS]ERROR {org.wso2.carbon.identity.mgt.util.Utils} - Unable to retrieve the claim for user : jacques.martin@mytenant.com org.wso2.carbon.user.core.UserStoreException: UserNotFound: User jacques.martin@mytenant.comdoes not exist in: PRIMARY at org.wso2.carbon.user.core.common.AbstractUserStoreManager.callSecure(AbstractUserStoreManager.java:168) at org.wso2.carbon.user.core.common.AbstractUserStoreManager.getUserClaimValues(AbstractUserStoreManager.java:697) at org.wso2.carbon.identity.mgt.util.Utils.getClaimFromUserStoreManager(Utils.java:189) at org.wso2.carbon.identity.mgt.util.Utils.getEmailAddressForUser(Utils.java:226) at org.wso2.carbon.identity.mgt.mail.AbstractEmailSendingModule.getNotificationAddress(AbstractEmailSendingModule.java:53) at org.wso2.carbon.identity.mgt.RecoveryProcessor.notifyWithEmail(RecoveryProcessor.java:541) at org.wso2.carbon.identity.mgt.services.UserInformationRecoveryService.registerUser(UserInformationRecoveryService.java:890) Same error with Pradeepa Wickramasinghe's answer.

My java code is as follow : userInformationRecoveryClient.registerUser(user.getUsername(), user.getPassword(), claims, "default", tenant ); In claims I have correctly set http://wwso2.org/claims/email

解决方案

Yes ,is it possible to used user name as both email or username. For that you need to follow the steps below,

  1. Enable the email user name by uncomment in [IS_HOME]/repository/conf/carbon.xml file as below,

<EnableEmailUserName>true</EnableEmailUserName>

  1. Add new property in to the [IS_HOME]/repository/conf/user-mgt.xml file as below,

<Property name="UsernameWithEmailJavaScriptRegEx">[a-zA-Z0-9@._-|//]{3,30}$</Property>

  1. Changed the "UsernameJavaRegEx" and "UsernameJavaScriptRegEx" in [IS_HOME]/repository/conf/user-mgt.xml file as below,

<Property name="UsernameJavaRegEx">[a-zA-Z0-9@._-|//]{3,30}$</Property>

<Property name="UsernameJavaScriptRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>

You can found more details here.

这篇关于WSO2 身份服务器电子邮件或伪作为用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆