Spring Security自定义用户授权表

Ana*_*man 5 spring-security

我想在我的网络应用程序中使用Spring Security 3.1.我已经开始关注这个特定的教程了.

我正在使用此处使用的技术,其中身份验证提供程序是数据源

<authentication-manager>
    <authentication-provider>
        <jdbc-user-service data-source-ref="dataSource"

           users-by-username-query="
              select email,password 
              from usr where email=?" 

           authorities-by-username-query="
              select u.email, ur.authority from usr u, usr_roles ur 
              where u.usr_id = ur.usr_id and u.email =?  " 

        />
    </authentication-provider>
</authentication-manager>
Run Code Online (Sandbox Code Playgroud)

因此,如果您发现我使用该电子邮件作为我的用户名,并且我没有启用的列.

这似乎不起作用.

我的登录表单看起来像

<form name="f" action="<c:url value="j_spring_security_check" />" method="POST">
    <table>
        <tr>
        <td>User:</td>
        <td><input type="text" name="j_username" value=""></td>
        </tr>
        <tr>
        <td>Password:</td>
        <td><input type="password" name="j_password" />
        </td>
        </tr>
        <tr>
        <td colspan="2">
                <input name="submit" type="submit" value="submit" />
            </td>
        </tr>
        <tr>
        <td colspan="2">
                <input name="reset" type="reset" />
        </td>
        </tr>
    </table>
</form>
Run Code Online (Sandbox Code Playgroud)

请告知如何使这个工作或我错过了什么?

Ana*_*man 5

我设法自己解决了.我已经修改了身份验证管理器配置,如下所示

<authentication-manager>
      <authentication-provider>

            <jdbc-user-service data-source-ref="dataSource"

           users-by-username-query="
              select * from (select email as username,password,1 as enabled 
              from usr) where username=?" 

           authorities-by-username-query="
             select * from
            (select u.email username, ur.authority AUTHORITY 
            from usr u, usr_role ur 
              where u.usr_id = ur.usr_id) where  username = ? " 

        />
      </authentication-provider>
    </authentication-manager>
Run Code Online (Sandbox Code Playgroud)