2017-01-17 4 views
-1

スプリングセキュリティを動作させることができません。私はsecurity:user-serviceと私のアプリケーションをテストし、それは完璧に動作します。私はスプリングセキュリティリターン403、ロギングが動作しない

<security:authentication-manager alias="authenticationManager"> 
    <security:authentication-provider> 
     <security:jdbc-user-service data-source-ref="dataSource" 
      users-by-username-query="SELECT name as username, password, 1 as enabled FROM cuser WHERE name=?;" 
      authorities-by-username-query="SELECT u.name as username, r.name as authority FROM cuser u join cuserrole ur on ur.iduser=u.id join crole r on r.id=ur.idrole where u.name=?;" /> 
    </security:authentication-provider> 
</security:authentication-manager> 

<security:user-service> 
    <security:user name="XX" password="XX" authorities="ROLE_EDITOR" />     
</security:user-service> 

を交換するときしかし、私はもはやそれを動作させることはできません。サーバーから403の応答を取得し続けます。私はdbでクエリを実行し、期待値を返します。

ロギング作業を行うことができないため、実際に何が起こっているのかをデバッグするのは難しいです。私はSO

How do I enable logging for Spring Security?

Debugging Spring configuration

に同様の問題を読みました は、ソリューションのナットはまだロギングは動作しませんしようとしました。誰かが何らかのアイデアを持っているなら、あなたの助けは相当なものです。

答えて

0

はそれを信じることができない...

春は私が403

+0

誰かが私にROLE_プレフィックスの理由を教えてもらえますか?ありがとう私は手作りの役割の名前を使用することはできませんか? – user2745862

0

クラスRoleVoterが財産rolePrefix

public class RoleVoter implements AccessDecisionVoter<Object> { 
    // ~ Instance fields 
    // ================================================================================================ 

    private String rolePrefix = "ROLE_"; 

    // ~ Methods 
    // ======================================================================================================== 

    public String getRolePrefix() { 
     return rolePrefix; 
    } 

    /** 
    * Allows the default role prefix of <code>ROLE_</code> to be overridden. May be set 
    * to an empty value, although this is usually not desirable. 
    * 
    * @param rolePrefix the new prefix 
    */ 
    public void setRolePrefix(String rolePrefix) { 
     this.rolePrefix = rolePrefix; 
} 
用セッターを持ってきた本のwork.becauseするセキュリティのためROLE_の接頭辞が必要です

したがって、このプロパティをRoleVoterに設定してAccessDecissionManagerに設定し、それを春のセキュリティhttpコンフィグレーションでaccess-decission-manager-refとして設定することができます

関連する問題