스프링 보안 버전 4.1을 사용하고 있습니다. 보안 설정에서 access="hasRole('ROLE_ADMIN')"
또는 access="ROLE_ADMIN"
을 지정하면 로그인 할 수는 있지만 관리자 페이지에 액세스 할 수 없습니다.스프링 보안이 "hasRole ('ROLE_ADMIN') '또는 ROLE_ADMIN과 작동하지 않습니다.
DEBUG [http-bio-8080-exec-10] [org.springframework.security.web.access.intercept.FilterSecurityInterceptor] Secure object: FilterInvocation: URL: /admin; Attributes: [hasRole('ROLE_ADMIN')]
2016-06-25 10:07:53,667 [] DEBUG [http-bio-8080-exec-10] [org.springframework.security.web.access.intercept.FilterSecurityInterceptor] Previously Authenticated: org.springframew[email protected]cc305a73: Principal: [email protected]: Username: francatore ; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMIN ; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]166c8: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 7F702A6911A71EA5556C750B6D424FF5; Granted Authorities: ROLE_ADMIN
2016-06-25 10:07:53,667 [] DEBUG [http-bio-8080-exec-10] [org.springframework.security.access.vote.AffirmativeBased] Voter: org.sp[email protected]170ea084, returned: -1
2016-06-25 10:07:53,668 [] DEBUG [http-bio-8080-exec-10] [org.springframework.security.web.access.ExceptionTranslationFilter] Access is denied (user is not anonymous); delegating to AccessDeniedHandler
내가 아마도 어떤 누락 될 수있다 : 아래
<security:http use-expressions="true">
<security:intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" />
<!-- security:intercept-url pattern="/admin" access="hasRole('ROLE_ADMIN')"/-->
<security:intercept-url pattern="/createmanufsensors" access="isAuthenticated()" />
</security:http>
<security:global-method-security secured-annotations="enabled"></security:global-method-security>
디버그 오류가?
롤은 사용자가 생성하고 계정 할 때 사용자에게 할당됩니다. 위의 사용자에게는 'ROLE_ADMIN'이 할당되고 나머지 사용자에는 'ROLE_USER'가 할당됩니다. 역할은 데이터베이스의 권한 테이블에 저장됩니다. –