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

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

问题描述

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

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 ?

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

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

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

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

我评论了 <Property name="UsernameJavascriptRegEx">当我添加没有 @ 的用户时,我得到:<代码>原因: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)

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)

如果我删除此标签 <Property name="UsernameJavaRegEx"> 我会收到以下错误:

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}- 无法检索用户的声明: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 的回答相同的错误.

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.

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

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

推荐答案

是的,是否可以将用户名同时用作 emailusername.为此,您需要按照以下步骤操作,

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

  1. 在[IS_HOME]/repository/conf/carbon.xml文件中uncomment启用邮件用户名,如下所示,
  1. Enable the email user name by uncomment in [IS_HOME]/repository/conf/carbon.xml file as below,

<EnableEmailUserName>true</EnableEmailUserName>

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

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

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

<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天全站免登陆