첫번째 - 구글 로그인 셋팅
1.Google API Console 검색
2.API Console - Google Cloud Platform 클릭 ㄱㄱ
3.서비스 약관 동의가 나오면 "동의 및 계속하기" 클릭
4."프로젝트 선택" 클릭 ㄱㄱ
5."새 프로젝트" 클릭 ㄱㄱ
6.프로젝트 이름 대충 만들고 "만들기" 클릭 ㄱㄱ
7."OAuth 동의 화면" 클릭 ㄱㄱ
8."외부" 선택하고 "만들기" 클릭 ㄱㄱ
9.앱 이름, 사용자 지원 이메일, 개발자 연락처 정보 입력하고 "저장 후 계속" 클릭 ㄱㄱ
11."사용자 인증 정보" 클릭 ㄱㄱ
12."사용자 인증 정보 만들기" -> "OAuth 클라이언트 ID" 순서대로 클릭 ㄱㄱ
13.이름, URI 입력하고 "만들기" 클릭 ㄱㄱ
:이름은 대충 입력해도 상관없음
:URI 주소를 입력할 때 Protocol, HostName, Port는 자신의 환경에 맞춰 작성하면 됨
:본 글에서는 OAuth-Client 라이브 러리를 사용하기 때문에 뒤에 경로는 고정으로 박아줘야함
:http(Protocol)://localhost(HostName):8080(Port)/login/oauth2/code/google
14.방금 생성한 클라이언트ID 클릭 후 클라이언트 ID, 클라이언트 보안 비밀 번호 확인
두번째 - 스프링 부트 셋팅
1.디펜던시에 OAuth2-Client 라이브러리 추가 ㄱㄱ
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
2.application.yml 수정 ㄱㄱ
:참고로 화면에 보이지는 않지만 Sppring: 밑에 security: 를 추가해야함
security:
oauth2:
client:
registration:
google:
client-id: Google 클라이언트 ID
client-secret: Google 클라이언트 보안 비밀 번호
scope:
- email
- profile
3.LoginForm.html 파일 수정 ㄱㄱ
:OAuth-Client 라이브 러리를 사용하면 아래 경로는 고정임
:/oauth2/authorization/google
4.SecurityConfig CLASS 수정 ㄱㄱ
.and()
.oauth2Login()
.loginPage("/loginForm");
세번째 - 테스트
1.일단 로그아웃 ㄱㄱ
2.구글 로그인 클릭 ㄱㄱ
3.계정 클릭 ㄱㄱ
4.짜잔!
-끝-
'Spring Boot > Security' 카테고리의 다른 글
[SpringBoot Secyruty] 구글 로그인 (2) (0) | 2022.04.24 |
---|---|
[SpringBoot Secyruty] 권한 처리 (0) | 2022.04.22 |
[SpringBoot Secyruty] 환경 설정 (0) | 2022.04.22 |
[SpringBoot Security] 로그인 페이지 만들기 (0) | 2022.04.22 |
[SpringBoot Secyruty] 회원가입 페이지 만들기 (0) | 2022.04.20 |