0

私の最初のSpring Webアプリケーションで認証関連の問題をすべて解決した後、私は承認に行き詰まっています。

注釈を使用した構成@Securedは非常に簡単なので、ここで間違いを犯したとは思いません。さらに、LDAP 認証プロバイダーを使用して Active Directory を使用しており、AD グループごとに役割を割り当てているため、これも問題ではありません。

だからここに私の問題の簡単な要約があります:

  • セキュリティで保護されていないアクションが機能する
  • 仕事を使ったアクション@Secured("IS_AUTHENTICATED_FULLY")
  • のようなものを使用したアクション@Secured("GROUP_*") は機能しません

保護されたアクションを呼び出すと、 aorg.springframework.security.AccessDeniedExceptionがスローされます。ログからの抜粋は次のとおりです。

DEBUG: org.springframework.security.intercept.AbstractSecurityInterceptor - Secure object: ReflectiveMethodInvocation: public org.springframework.web.servlet.ModelAndView de.dillinger.resources.controllers.HostsController.index(); target is of class [de.dillinger.resources.controllers.HostsController]; ConfigAttributes: [GROUP_IT]
DEBUG: org.springframework.security.intercept.AbstractSecurityInterceptor - Previously Authenticated: org.springframework.security.providers.UsernamePasswordAuthenticationToken@2a5333d9: Principal: org.springframework.security.userdetails.ldap.Person@1422384: Username: di32001; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: GROUP_ITS, GROUP_ITS-IT, GROUP_INTERNET, GROUP_SYSTEMGRUPPE, GROUP_IT; Password: [PROTECTED]; Authenticated: true; Details: org.springframework.security.ui.WebAuthenticationDetails@0: RemoteIpAddress: 127.0.0.1; SessionId: 773943FFB14E512872BB6CE25F46C00A; Granted Authorities: GROUP_ITS, GROUP_ITS-IT, GROUP_INTERNET, GROUP_SYSTEMGRUPPE, GROUP_IT

ご覧のとおり、アクションにはGROUP_ITロールが必要であり、私のユーザー オブジェクトにはこの権限があります。この問題の原因は本当にわかりません。

4

1 に答える 1

2

org.springframework.security.access.vote.UnanimousBased役割投票者を使用していますか? に変更してみてくださいorg.springframework.security.access.vote.AffirmativeBased
この種の問題は、役割投票者の構成に関連しています。

編集1(例を追加):

<security:global-method-security 
    secured-annotations="enabled"  
    access-decision-manager-ref="accessDecisionManager"
/>
<bean 
    id="accessDecisionManager" 
    class="org.springframework.security.access.vote.AffirmativeBased">
    <property name="allowIfAllAbstainDecisions" value="false" />
    <property name="decisionVoters">
        <list>
            <bean id="roleVoter" class="org.springframework.security.access.vote.RoleVoter" />
        </list>
    </property>
 </bean>
于 2009-09-18T14:00:37.683 に答える