사전에 Spring Security 설정은 되어있어야 진행된다.
SecurityContext sc = SecurityContextHolder.getContext();
//ID, PW, 권한을 설정합니다. PW는 null 이어도 상관없음
sc.setAuthentication(new UsernamePasswordAuthenticationToken(id, null, role)); // (id, pw, 권한)
//Spring security 세션에 등록
httpSession.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, sc);
'Spring' 카테고리의 다른 글
Spring Security Password 비교! matches 사용시 주의사항! (0) | 2022.01.03 |
---|---|
[Spring] Sign in with Apple 기능 구현 완전체!! (0) | 2021.12.02 |
SpringBoot Session TimeOut 설정! (0) | 2021.06.14 |
[SpringBoot] Session 으로 Login 처리! (0) | 2021.03.26 |
Spring 특정 URL만 encoding 다르게 처리하기 (0) | 2021.01.21 |