2012-05-08 14 views
4

WebアプリケーションでSpring Security 3.1を使用しようとしています。私はこの特定のtutorialに続いて始めました。あなたは、私は自分のユーザー名として電子メールを使用してい気づくと私は有効に列を持っていない場合は、認証プロバイダにデータソースにそうSpring Securityカスタムユーザ権限テーブル

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

です

私はここで使用される技術を使用しています。

これは機能していないようです。

私のログインフォームは

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

どのように見えるか、この作業を取得するか、私が何かをしないのですへと助言してください?

答えて

4

私はそれを自分で解決することができました。私は次のように認証マネージャの設定を変更しました

<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> 
関連する問題