【问题标题】:How to make case insensitive username authentication in hybris?如何在 hybris 中进行不区分大小写的用户名身份验证?
【发布时间】:2016-11-14 17:06:27
【问题描述】:

如何在hybris中进行不区分大小写的用户名认证?

【问题讨论】:

    标签: java spring-security hybris


    【解决方案1】:

    首先你必须重写 DefaultCustomerFacade 的 register 方法(在 commercefacades 中的文件)。

    你会发现默认实现强制小写阻止你在你的 uid 中使用大写字符 --> customer.setUid(registerData.getLogin().toLowerCase())

    然后你必须创建一个具有别名“acceleratorAuthenticationProvider”的新 bean,它会覆盖方法 authenticate。

    在这个方法中你必须实现类似的东西

    final UserModel userModel = findUserCaseInsensitive(authentication.getName());
    if (userModel != null)
    {
        usernameResult = userModel.getUid();
        token = new UsernamePasswordAuthenticationToken(authentication.getName(), authentication.getCredentials());
        token.setDetails(authentication.getDetails());
    }
    

    findUserCaseInsensitive 方法应该调用一个执行灵活搜索的 DAO。 这是一个例子:

    SELECT {user.PK} FROM {User as user} WHERE lower({user.uid}) = lower(?uid)

    【讨论】:

      猜你喜欢
      • 2021-11-03
      • 2020-08-09
      • 1970-01-01
      • 2012-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-26
      • 1970-01-01
      相关资源
      最近更新 更多