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

问题描述

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

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

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

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

我评论了

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

[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] [email protected]@mytenant.com [1] [IS]ERROR {org.wso2.carbon.identity.mgt.util.Utils} - Unable to retrieve the claim for user : jacques.martin@mytenant.comorg.wso2.carbon.user.core.UserStoreException: UserNotFound: User [email protected] 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 身份服务器电子邮件或伪作为用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 18:38