feat: spring security OAuth2 관련 설정 추가

This commit is contained in:
kimjunseo
2021-07-23 00:28:51 +09:00
parent eebd3a9585
commit 9832ae0b76
2 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package com.example.oauthspringsecurity.config;
import com.example.oauthspringsecurity.service.OAuthService;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableWebSecurity // spring security 설정을 활성화시켜주는 어노테이션
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private final OAuthService oAuthService;
public SecurityConfig(OAuthService oAuthService) {
this.oAuthService = oAuthService;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.oauth2Login() // OAuth2 로그인 설정 시작점
.userInfoEndpoint() // OAuth2 로그인 성공 이후 사용자 정보를 가져올 때 설정 담당
.userService(oAuthService); // OAuth2 로그인 성공 시, 후작업을 진행할 UserService 인터페이스 구현체 등록
}
}