본문 바로가기
728x90
반응형

spring/spring security9

Spring Security 5에서 Spring Security 6으로 변경 (URL-권한 인가) 스프링 부트 3.0부터 스프링 시큐리티 6 버전이 적용되었습니다. 삭제되거나 deprecated된 코드가 많아서 마이그레이션 시 주의할 부분에 대해 알려드리겠습니다. 기존 버전 : 5.3.3.RELEASE최신 버전 : 6.2.4 기존 WebSecurityConfigurationAdapter를 상속받아 세팅하던 방식은 삭제되었고 SecurityFilterChain bean을 스프링 컨테이너에 등록해줘야함.authorizeRequests() → authorizeHttpRequests()로 변경antMatchers() → requestMatchers()로 변경로그인 페이지 리다이렉트 반복 접근 이슈 발생.dispatcherTypeMatchers(DispatcherType.FORWARD).permitAll() .. 2024. 4. 30.
[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 Security5] 권한 계층구조(roleHierarchy) 설정 1. roleHierarchy 설정인가 관련해서는 AccessDecisionManager를 사용합니다. SecurityContextHolder에 저장되어있는 Authentication이 접근하는 리소스에 적절한 ROLE을 가지고 있는지 확인합니다. 확인하는 방법은 세 가지(AffirmativeBased, ConsensusBased, UnanimousBased)가 있는데 그중 AffrimativeBased(여러 Voter 중 하나라도 허용하면 허용)를 기본전략으로 사용합니다.<pre id="code_1628819619550" class="java" data-ke-language="java" dat.. 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 Security5] SecurityFilterChain, Filter 이중 호출 해결 (Filter disabled) Multiple HttpSecurity 구성에서 서비스를 이동할 때, 각 서비스에서 사용하는 권한으로 변경하는 필터 AuthorityChangeFilter를 등록하려고 합니다.​​<p id="SE-cd093979-c8b7-433d-a3ce-f7414916109f" dat.. 2020. 10. 31.
[Spring Security5] Multiple HttpSecurity, Multiple Login, accessDenied 설정 한 프로젝트에 여러 개 서비스가 있을 경우, 로그인 화면이 두 개 이상인 경우 다음과 같이 구성합니다.​MultipleSecurityConfiguration.java (<a href="https://docs.spring.io/spring-security/site/docs/4.1.5... 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
반응형