【问题标题】:Cannot authenticate through JBoss AS 7 security subsystem无法通过 JBoss AS 7 安全子系统进行身份验证
【发布时间】:2014-03-16 22:31:17
【问题描述】:

我不明白如何使用密码的哈希值而不是开放密码。 当我从我的 MS SQL 数据库中获取开放密码时,一切正常。 standalone.xml:

<security-domain name="SD" cache-type="default">
 <authentication>
  <login-module code="Database" flag="required">
   <module-option name="dsJndiName" value="<jndi>"/>
   <module-option name="principalsQuery" value="select <open_pass> from <table> where <username> = ?"/>
   <module-option name="rolesQuery" value="select <role>, 'Roles' from <table> where <username> = ?"/>       
  </login-module>
 </authentication>
</security-domain>

web.xml

<security-constraint>
    <display-name>General</display-name>
    <web-resource-collection>
        <web-resource-name>/</web-resource-name>
        <description/>
        <url-pattern>/</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <description/>
        <role-name>administrators</role-name>
    </auth-constraint>
</security-constraint>
<login-config>
    <auth-method>BASIC</auth-method>
</login-config>
<security-role>
    <description/>
    <role-name>administrators</role-name>
</security-role>

但是当我尝试使用类似以下的东西时:

<security-domain name="SD" cache-type="default">
 <authentication>
  <login-module code="Database" flag="required">
   <module-option name="dsJndiName" value="<jndi>"/>
   <module-option name="principalsQuery" value="select <pass_hash> from <table> where <username> = ?"/>
   <module-option name="rolesQuery" value="select <role>, 'Roles' from <table> where <username> = ?"/>
   <module-option name="hashAlgorithm" value="SHA-1"/>
   <module-option name="hashEncoding" value="base64"/>       
  </login-module>
 </authentication>
</security-domain>

即使我输入正确的密码,我也会获得Login failure: javax.security.auth.login.FailedLoginException: Password Incorrect/Password Requiredpass_hash 字段在数据库中有 varbinary(64) 类型。 我错过了什么?

【问题讨论】:

    标签: java security jboss subsystem container-managed


    【解决方案1】:

    请查看DatabaseServerLoginModule

    您是否也将 base64 编码的密码存储在 users 表中。

    【讨论】:

    • 我将 SHA-1 密码的哈希值存储在 varbinary(64) 字段中并获取它。
    • 我尝试在 varchar 字段中存储密码哈希并在hashEncoding 标签中输入hex,但它仍然不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-15
    • 1970-01-01
    • 2012-04-01
    • 2014-01-05
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    相关资源
    最近更新 更多