전체 글

    SpringSecurity - Test 작성

    개요 Spring Test 를 작성하려고 하다보면, 인증이 필요한 부분이 있습니다. 인증이 필요한 부분에 간단하게 인증을 추가할 수 있는 방법을 소개하겠습니다. 해당 내용은 모두 스프링 공식 문서에서 확인할 수 있습니다.[https://docs.spring.io/spring-security/site/docs/current/reference/html5/#test-method] Annotation 기본적으로 SecrutityContext 는 method 테스트 직전에 초기화 되는데, 옵션을 통해 테스트 실행시에 한번만 초기화 되도록 할 수 있습니다@WithMockUser(setupBefore = TestExecutionEvent.TEST_EXECUTION) @WithMockUser username, role..

    Swagger - API 문서 자동화

    Swagger Swagger 는 annotation 기반의 REST API 문서를 만들어주는 프레임워크입니다. 간단하게 dependecy 를 추가하여 사용할 수 있습니다. io.springfox springfox-swagger2 2.9.2 Configration @Configuration @EnableSwagger2 public class Swagger2Configure implements WebMvcConfigurer { // Swagger SecurityConfiguration Bean 설정 @Bean public SecurityConfiguration security() { return SecurityConfigurationBuilder.builder() .scopeSeparator(",") .ad..

    Spring Security(2) - SecurityContext

    Security Filter 에서 인증된 정보를 저장하는 SecurityContext 에 대해 알아보겠습니다. SecurityContext 는 접근 주체와 인증에 대한 정보를 담고 있는 Context 입니다. 접근 주체인 Authentication 을 담고 있습니다. 정확히는 SecurityContextHolder 가 SecurityContextHolderStrategy 를 통해 SecurityContext 를 반환할 수 있고, SecurityContext 가 담고 있는 Authentication 정보를 가져올 수 있습니다. Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); 위와 같은 형태로 P..

    Spring Security (1) - FilterChainProxy

    Spring Security 는 Servlet Filter 의 구현체들로 필터체인을 구성하여 인증 및 인가를 처리합니다. Spring Security configuration 시큐리티 설정 구성은 WebSecurityConfigurerAdapter 를 상속받아 configure 메서드를 오버라이딩 하여 구성할 수 있습니다. @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .mvcMatchers("/")..

    인텔리제이 새로운 프로젝트 github 연동

    1. 프로젝트를 만든다. 2. 로컬 repository 생성 3. github 에 새로운 repository 생성 (생성한 주소 복사) 4. VCS -> git -> Remotes... 에 복사한 주소 넣음 5. 터미널에서 명령어로 연결 확인 (git remote -v)