인메모리 인가방식 질문드립니다.
224
작성한 질문수 4
안녕하세요 강사님,
실전강의 관련하여 추가질문드립니다.
아래 MapBasedUrlRoleMapper쪽에서
ROLE_ 으로 시작되는 권한은 PersistentUrlRoleMapper를 통해 DB에서 불러오고 나머지는 MapBasedUrlRoleMapper를 사용해서 명시를 할 수 있을까요?
public class MapBasedUrlRoleMapper implements UrlRoleMapper{
private final LinkedHashMap<String, String> urlRoleMappings = new LinkedHashMap<>();
@Override
public Map<String, String> getUrlRoleMappings() {
urlRoleMappings.put("/", "permitAll");
urlRoleMappings.put("/css/**", "permitAll");
urlRoleMappings.put("/js/**", "permitAll");
urlRoleMappings.put("/images/**", "permitAll");
urlRoleMappings.put("/favicon.*", "permitAll");
urlRoleMappings.put("/*/icon-*", "permitAll");
urlRoleMappings.put("/signup", "permitAll");
urlRoleMappings.put("/login", "permitAll");
urlRoleMappings.put("/logout", "permitAll");
urlRoleMappings.put("/denied", "authenticated");
urlRoleMappings.put("/", "ROLE_USER");
urlRoleMappings.put("/user", "ROLE_USER");
urlRoleMappings.put("/admin/**", "ROLE_ADMIN");
urlRoleMappings.put("/manager", "ROLE_MANAGER");
urlRoleMappings.put("/db", "hasRole('DBA')");
return new HashMap<>(urlRoleMappings);
}
}
답변 1
0
네
일단 강의에서는 두개의 유형을 어떤 조건에 따라 스위칭 하도록 되어 있지는 않습니다.
이 부분은 사실 설계의 문제이고 설계에 따라 어떻게 구현할 것인지의 부분이라 질문하신 흐름을 어떻게 처리할 것인지 고민해야 할 것 같습니다.
MapBasedUrlRoleMapper 와 PersistentUrlRoleMapper 는 전략패턴처럼 사용되고 있기 때문에 ROLE_ 로 시작할 때는 PersistentUrlRoleMapper 를 넘겨주고 그외에는 MapBasedUrlRoleMapper 를 넘겨주는 식으로 할 수 있지만 ROLE_ 로 시작하는 분기문을 어떤 기준으로 가져오거나 구성할 지는 여러 가지로 고민해야 할 부분입니다.
왜냐하면 ROLE_ 접두어는 맵이든 DB 든 권한 정보에 포함되는 데이터이기 때문에 맵이나 DB 를 구분할 수 있는 기준이 가능한지부터 판단해 보아야 합니다
로그아웃-logout()-2 강에서 겟방식 로그아웃 호출 후 화면이동 질문입니다.
0
36
2
단원별 소스코드
0
66
2
CustomAuthenticationProvider 추가 관련 문의
0
78
2
AOP 의존성 명칭 변경
0
77
1
빈 1개 등록 시 다른 해결 방법
0
70
1
@Bean으로 AuthenticationProvider를 등록 시 http.authenticationProvider 함수를 이용해서 추가해줘야되나요?
0
87
2
OIDC의 id token에 담긴 데이터에 대해
0
78
1
loginPage("/loginPage") 질문드립니다.
0
69
1
@EnableWebSecurity
0
148
1
트랜잭션과 롤백
0
100
1
68. 인증 이벤트 - AuthenticationEventPublisher 활용 강좌 음성 문제
0
91
2
AuthenticationManager 사용 방법
0
153
2
HttpSecurity.authorizeHttpRequests() - 2 강의 부분에 대한 질문
0
108
2
spring security 6.3에서는 HttpSecurity가 만들어지기 전 WebSecurity가 먼저 만들어지는게 맞나요??
0
192
1
init(B Builder), configure(B builder) 에 대하여 질문 드립니다.
0
109
2
메타 주석 질문
0
69
1
동시세션제어 기능에서 로그아웃하기
0
153
3
로그인 후, redirect 에서 error
0
141
3
Session 생성 타이밍에 대한 질문
0
86
2
강의 참고 내용을 개발 로그로 작성해도 될지 문의드립니다.
0
135
2
customAuthentication 관련
0
132
2
authenticationManagerBuilder 주입받은거 vs 만든 거
0
114
1
UserDetailsService()에서 UserDetail이 아닌 타입을 반환할 수 있나요?
0
101
1
9:28 패턴 3의 경우 마지막으로 설정한 것만 적용되는 것 같습니다.
0
162
2





