Spring Security Custom User Authorization Tables

spring-security

Solution

I managed to solve it myself. I have modified the authentication-manager configuration as follows

<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>

Problem

I am trying to use Spring Security 3.1 in my web app. I have started off with following this particular tutorial. I am using the technique used here where in authentication provider is a datasource ``` <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> ``` So if you notice I am using the email as my username and I do not have a enabled column. This does not seem to work. My login form looks like ``` <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> ``` Please advise as to how to get this working or am I missing something ?

Original source