@secured는 역할이 정확하지만 AccessDeniedException을 던졌습니다
-
22-07-2019 - |
문제
모든 것을 해결 한 후 인증 관련 문제 첫 번째 스프링 웹 응용 프로그램에서 이제는 승인이 고착되었습니다.
사용 구성 @Secured
주석은 꽤 직접적으로 이루어 지므로 여기서 실수를하지 않았다고 생각합니다. 또한 LDAP 인증 제공 업체를 사용하여 Active Directory를 사용하고 광고 그룹에서 역할을 할당하므로 문제가되지 않습니다.
여기 내 문제에 대한 간단한 요약이 있습니다.
- 무담보 행동 일하다
- 사용하는 작업
@Secured("IS_AUTHENTICATED_FULLY")
일하다 - 같은 것을 사용하는 행동
@Secured("GROUP_*")
작동하지 마십시오
보안 조치를 호출 할 때 a org.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
역할과 내 사용자 객체에는이 권한이 있습니다. 나는이 문제를 일으키는 원인을 정말로 모른다.
해결책
당신은 사용하고 있습니까? 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>
제휴하지 않습니다 StackOverflow