일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- Zuul
- 유레카
- 백트래킹
- 트리
- Java
- 게이트웨이
- 이분 매칭
- 이분 탐색
- 서비스 디스커버리
- 비트마스킹
- 플로이드 와샬
- spring boot
- 구간 트리
- Spring Cloud Config
- 완전 탐색
- docker-compose
- 스택
- dp
- Gradle
- Logback
- BFS
- ZuulFilter
- 구현
- 메모이제이션
- 주울
- 도커
- 스프링 시큐리티
- 달팽이
- 다익스트라
- spring cloud
- Today
- Total
목록Spring boot/Security (4)
Hello, Freakin world!
프로젝트에서 스프링 시큐리티를 사용하는 경우, WebSecurityConfigurerAdapter 상속 클래스에서 CORS 설정을 추가해야 합니다. @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ... @Override protected void configure(HttpSecurity http) throws Exception { http .csrf().disable() .cors().configurationSource(corsConfigurationSource()).and() .authorizeRequests() .antMatchers("/login/**", "/hello/**").permi..
간단하게 몇 개의 url 접근에 필요한 권한을 설정하고 mock 테스트를 작성해보자. 아래와 같이 url 권한을 설정, 요청에 csrf 토큰을 추가하도록 설정했다. csrf 설정을 하게 되면 위험할 수 있는 요청(POST, DELETE, PUT)의 경우 반드시 csrf 토큰을 요청에 포함해야 된다. WebSecurityConfig import org.springframework.http.HttpMethod; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.bu..

시나리오 - 인증 기능을 구현한다. - 로그인 화면에서 인증 요청을 받는다. - 인증 요청 정보를 Member 데이터베이스에 저장된 정보와 대조해 인증한다. 1. 로그인 화면 스프링 시큐리티에 form 로그인 방식 설정을 해두면 위와 같이 동작합니다. 보호된 자원에 접근하는 경우, AccessDeniedException이 발생합니다. ( 폼 로그인 설정이 없을 경우 단순하게 403 Forbidden 에러 페이지를 보여줍니다.) SecurityFilterChain에 등록되어 있는 예외처리 필터에서 AccessDeniedException을 캐치해 로그인 화면으로 클라이언트를 리다이렉트 시킵니다. form 로그인을 설정하는 코드는 아래와 같습니다. ... @EnableWebSecurity public clas..
... public class TestPasswordEncoder { @Test public void delegatingPasswordEncodingTest() { //given String givenPassword = "hello"; //when PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder(); String encodedPassword = passwordEncoder.encode(givenPassword); //then assertThat(passwordEncoder.matches(givenPassword, encodedPassword)).isTrue() ; } @Test public ..