본문 바로가기
728x90
반응형

spring/spring security8

[Spring Security] DaoAuthenticationProvider org.springframework.security.authentication.dao.DaoAuthenticationProvider DaoAuthenticationProvider는 UserDetailsService 및 PasswordEncoder를 사용하여 사용자 아이디와 암호를 인증하는 AuthenticationProvider 구현입니다. The authentication Filter는 ProviderManager에 의해 구현되는 AuthenticationManager에 UsernamePasswordAuthenticationToken을 전달합니다. ProviderManager는 DaoAuthenticationProvider 타입의 AuthenticationProvider를 사용하도록 구성됩니다. Dao.. 2023. 5. 9.
[Spring Security] DelegatingPasswordEncoder와 BCryptPasswordEncoder strength에 따른 수행시간 DelegatingPasswordEncoder에 대해 정리하기 전에, 스프링 시큐리티 래퍼런스 내용을 살펴보겠습니다. Srping Password Storage Spring Security’s PasswordEncoder interface is used to perform a one way transformation of a password to allow the password to be stored securely. Given PasswordEncoder is a one way transformation, it is not intended when the password transformation needs to be two way (i.e. storing credentials used to auth.. 2022. 3. 20.
[Spring Security] 권한 계층구조(roleHierarchy) 설정 1. roleHierarchy 설정 인가 관련해서는 AccessDecisionManager를 사용합니다. SecurityContextHolder에 저장되어있는 Authentication이 접근하는 리소스에 적절한 ROLE을 가지고 있는지 확인합니다. 확인하는 방법은 세 가지(AffirmativeBased, ConsensusBased, UnanimousBased)가 있는데 그중 AffrimativeBased(여러 Voter 중 하나라도 허용하면 허용)를 기본전략으로 사용합니다. @Configuration public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Override public void configure(WebSecur.. 2021. 8. 13.
[Spring Security] redis 세션에서 SecurityContext 수정 FindByIndexNameSessionRepository의 save 메소드를 사용하여 SecurityContext 수정할 수 있습니다. @Resource(name = "sessionRepository") private FindByIndexNameSessionRepository findByIndexNameSessionRepository; public void refreshSecurityContext(String targetUsername) { // targetUsername의 session 모두 조회 Map sessionMap = findByIndexNameSessionRepository.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRI.. 2021. 7. 12.
[Spring] Chrome 양식 다시 제출 확인 ERR_CACHE_MISS 해결방법 Chrome에서 POST 요청으로 페이지 이동후 뒤로 가기를 하면 아래와 같은 확인 페이지를 제공하도록 되어있습니다. ​ ​ ​Spring security를 사용하면 headers cacheControl를 disabled 처리함으로써 해결합니다. @Configuration @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) { http // ... .headers(headers -> headers .cacheControl(cache -> cache.disable()) ); } } Cache Control.. 2020. 10. 31.
[Spring Security] SecurityFilterChain, Filter 이중 호출 해결 (Filter disabled) Multiple HttpSecurity 구성에서 서비스를 이동할 때, 각 서비스에서 사용하는 권한으로 변경하는 필터 AuthorityChangeFilter를 등록하려고 합니다. ​​ 우선 SecurityFilterChain 구성을 보면, ​ ​ ​ ​ ​ ​SecurityFilterChain은 Filter 보다 먼저 실행됩니다. AuthorityChangeFilter(권한을 변경하여 적용하기 위한 Filter)를 SecurityFilterChain이 아닌 Filter로 등록하면, 서비스를 이동할 때(user -> admin) SecurityFilterChain-FilterSecurityInterceptor에서 보유 중인 권한(user 권한)으로 접근 권한을 확인하여 해당 페이지의 접근 권한(admin 권.. 2020. 10. 31.
[Spring Security] Multiple HttpSecurity, Multiple Login, accessDenied 설정 한 프로젝트에 여러 개 서비스가 있을 경우, 로그인 화면이 두 개 이상인 경우 다음과 같이 구성합니다. ​ MultipleSecurityConfiguration.java (Spring docs 기반으로 작성.) @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) @Deprecated public class MultipleSecurityConfiguration { // spring security에서 허용할 web 리소스 path public static final String[] SECURITY_EXCLUDE_PATTERN_ARR = { "/" // resource.. 2020. 10. 31.
[spring security] URL 더블슬래시 허용 - The request was rejected because the URL was not normalized. Spring security의 기본정책은 URL에 더블 슬래시가 들어가는 것을 허용하지 않습니다. 예를 들어 https://moonsiri.tistory.com/category와 같은 URL을 사용할 때, URL 더블 슬래시 처리가 안되어있는 상태에서 https://moonsiri.tistory.com//category로 요청이 들어오면 에러가 발생합니다. org.springframework.security.web.firewall.RequestRejectedException: The request was rejected because the URL was not normalized. at org.springframework.security.web.firewall.StrictHttpFirewall.getF.. 2020. 10. 14.
728x90
반응형