-
[스프링] 시큐리티 - 7 (AccessDecisionManager)Spring 2020. 10. 11. 16:25
- 참고 : 인프런 >>스프링 시큐리티 (백기선 강의) 인증 ? AuthenticationManager 인가 ? AccessDecisionManager AccessDecisionManager Access Control 결정을 내리는 인터페이스로 여러개의 voter를 가질 수 있다. 여러 목록의 voter를 거치면서 유효한 지 확인 스프링 시큐리티가 기본적으로 3개의 인터페이스 구현체를 제공 AffirmativeBased: 여러 Voter중에 한명이라도 허용하면 허용. 기본 전략. ConsensusBased: 다수결 UnanimousBased: 만장일치 * AccessDecisionVoter 특정 오브젝트에 접근 할 때, 만족하는지 확인 WebExpressionVoter: 웹 시큐리티에서 사용하는 기본 구..
-
[스프링] 시큐리티 -6 (Filter)Spring 2020. 10. 11. 15:08
- 참고 : 인프런 >>스프링 시큐리티 (백기선 강의) AuthenticationManager가 인자로 받은 유저 인증 정보 "Authentication"을 Provider로 부터 인증을 마친 후 리턴 받은 Authentication(Principal, ...)의 행방 ? DelegatingFilterProxy 일반적인 서블릿 필터 서블릿 필터 처리를 스프링에 들어있는 빈에게 위임하고 싶을 때 사용하는 서블릿 필터. 스프링 부트를 사용할 때 자동으로 등록 (SecurityFilterAutoConfiguration) 스프링 시큐리티 Filter / FilterChainProxy 스프링 시큐리티 필터는 아래 설정에 따라 시큐리티 필터를 등록 위와 같은 설정을 여러개 있다면, SecurityFilterChai..
-
[스프링] 시큐리티 -5 (Authentication Manager)Spring 2020. 10. 10. 18:46
- 참고 : 인프런 >>스프링 시큐리티 (백기선 강의) Authentication Manager 사용자 아이디 / 비밀번호 인증을 처리하는 곳 -> 유효한 인증인지 확인 인자로 받은 Authentication이 유효한 인증인지 확인하고, "Authentication" 객체를 리턴 유저의 요청 내에 담긴 "Authentication"를 Authentication Manager 에 넘겨주고, AuthenticationProvider에서 인증을 처리한다. -> Authentication Manager은 인자로 받은 Authentication을 Provider을 통해, 유효한지 처리하여, "Authentication" 객체를 리턴한다. * Authentication 인자로 받은 필요한 정보 (username, ..
-
[스프링] 시큐리티 -4 (SecurityContextHolder)Spring 2020. 10. 9. 19:05
- 참고 : 인프런 >>스프링 시큐리티 (백기선 강의) SecurityContextHoder SecurityContext 제공 -> 기본적으로 ThreadLocal을 사용하여 SecurityContext를 제공 ThreadLocal을 사용하여 어디에서나 접근 할 수 있다. (스레드가 달라지면 다른 전략을 고민) 최종적으로 "Authentification" 객체를 담고 있다. * ThreadLocal(ThreadLocal) ? 동일 스레드 내에서 공용으로 사용하는 저장소 Java.lang 패키지에서 제공하는 쓰레드 범위 변수, 즉 쓰레드 수준의 데이터 저장소 각 스레드마다 독립적인 변수를 가지고 get(), set() 메소드를 통해 값에 대해 접근 한 스레드내에서 공용으로 사용하기 때문에, 파라미터로 데이..
-
[스프링] 시큐리티 -3 (Test)Spring 2020. 10. 9. 18:17
- 참고 : 인프런 >>스프링 시큐리티 (백기선 강의) [준비] 1. Security Test 의존성 추가 testCompile("org.springframework.boot:spring-boot-starter-test") testImplementation 'org.springframework.security:spring-security-test' [Junit Mock Mvc Test] 1. anonymousUser 요청 @WithAnonymousUser @Test @WithAnonymousUser//Anonymouse User 추가 public void index_anonymous() throws Exception { mockMvc.perform(get ("/")) .andDo(print()) .and..
-
[스프링] 시큐리티 - 2 (DB 연동)Spring 2020. 10. 5. 19:02
- 참고 : 인프런 >>스프링 시큐리티 (백기선 강의) - 참고 : github [준비] 1. JPA 의존성 추가 2. H2 Database 의존성 추가 org.springframework.boot spring-boot-starter-data-jpa com.h2database h2 runtime "UserDetailsService" ? - 스프링 시큐리티에서 제공 - 스프링 시큐리티에서 DAO(Data access object) 구현체를 통해 User의 정보를 가져와 "UserDetails" 타입으로 캐스팅 ex) 예제 1. 유저 정보를 DB에서 찾는다. >> "user" Account account = accountRepository.findByUsername(username); 2. "user" >>..
-
[스프링] 시큐리티 - 1 (인메모리 유저)Spring 2020. 10. 5. 17:59
- 참고 : 인프런 >>스프링 시큐리티 (백기선 강의) [스프링 시큐리티 의존성 추가] org.springframework.boot spring-boot-starter-security >> 추가 이 후, 모든 요청은 인증 필요 기본 유저 생성 Username : user Password : 콘솔에 출력 Using generated security password: 32b63478-00fc-4560-8b71-24bbed8438e7 [스프링 시큐리티 설정] @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSe..
-
[JAVA] 다이나믹 프록시 - 2Java 2020. 10. 4. 17:06
- 참고 : 인프런 >> 더 자바, 코드를 조작하는 다양한 방법, (백기선 강의) 다이나믹 프록시 1. JDK Proxy (java.lang.refelction.proxy) 반드시 Interface가 정의 되어있어야 한다. 런타임시 동적으로 생성 InvocationHandler 라는 Interface를 구현 invoke 메소드 Override하여 Proxy의 위임 기능을 수행 'Object'에 대해 Reflection기능을 사용하여 기능을 구현 [예제 코드] @Test public void test_다이나믹_프록시() { BookService bookService = (BookService) Proxy.newProxyInstance(BookService.class.getClassLoader(), new ..