Spring Security에서 role은 기본적으로 "ROLE_"로 시작해야 한다. 그렇지 않으면 오류를 뱉어낸다. 만약 "PRIV_" 등 다른 접두사를 사용하거나 특별한 네임 규칙이 없는 다른 role명을 사용하던 기존 시스템에 Spring Security를 연결해야 한다면 추가적인 설정이 필요하다.
다음과 같이 Access Decision Manager를 정의하고, RoleVoter에 prefix를 재설정하면 된다.
<security:http auto-config="true"
access-decision-manager-ref="accessDecisionManager">
...
</security:http>
<bean id="accessDecisionManager"
class="org.springframework.security.vote.AffirmativeBased">
<property name="allowIfAllAbstainDecisions" value="false" />
<property name="decisionVoters">
<list>
<bean class="org.springframework.security.vote.RoleVoter">
<property name="rolePrefix" value="" /> <-- ROLE_ -->
</bean>
</list>
</property>
</bean>'스프링' 카테고리의 다른 글
| SecurityConfig (0) | 2022.05.25 |
|---|---|
| Spring Boot Sample (0) | 2021.03.07 |
| Singleton Registry = ApplicationContext의 또 다른 이름 (0) | 2012.08.31 |
| MappingJacksonJsonView 쓸 때 JSON 밖으로 빼는 법(How to return a single JSON list) (0) | 2012.08.10 |
| Spring Security - username 정보 가져오기 (0) | 2012.01.09 |