CommonOAuth2Provider
Spring Boot 2.0 버전(Spring Security 5 이상)에서 제공하는 enum 클래스이다. 구글, 깃허브, 페이스북, 옥타의 OAuth2.0 Provider들의 기본 설정을 포함하고 있다. CommonOAuth2Provider 을 사용하면 설정 파일에서 client-id 와 client-secret만 설정하면 되고 나머지 설정은 CommonOAuth2Provider에서 제공하는 기본 설정을 사용하면 된다. (입력하지 않아도 된다.)
CommonOAuth2Provider에는 google의 기본 설정을 포함하기 때문에 client-id 와 client-secret 정보만 입력해주었다. 하지만 카카오와 네이버의 정보는 없기 때문에 provider 설정값을 네이버 아이디 로그인 API, 카카오 로그인 API 문서를 확인해서 직접 입력해주면 된다.
spring:
security:
oauth2:
client:
registration:
google:
client-id: your-google-client-id
client-secret: your-google-client-secret
scope: openid,profile,email
naver:
client-id: your-naver-client-id
client-secret: your-naver-client-secret
authorization-grant-type: authorization_code
redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
scope: name,email,profile_image
client-name: Naver
provider: naver
kakao:
client-id: your-kakao-client-id
client-secret: your-kakao-client-secret
authorization-grant-type: authorization_code
redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
scope: profile,account_email
client-name: Kakao
provider: kakao
provider:
naver:
authorization-uri: https://nid.naver.com/oauth2.0/authorize
token-uri: https://nid.naver.com/oauth2.0/token
user-info-uri: https://openapi.naver.com/v1/nid/me
user-name-attribute: response
kakao:
authorization-uri: https://kauth.kakao.com/oauth/authorize
token-uri: https://kauth.kakao.com/oauth/token
user-info-uri: https://kapi.kakao.com/v2/user/me
user-name-attribute: id
Reference
스프링 부트와 AWS로 혼자 구현하는 웹 서비스 (책)
'Project > SpringBoot를 사용해서 웹 서비스를 만들어보자' 카테고리의 다른 글
[코드 분석]Stream, map, collect (0) | 2023.08.22 |
---|---|
템플릿 엔진이란 (0) | 2023.08.22 |
Spring 웹 계층 (0) | 2023.08.18 |
자주 사용하는 Lombok 어노테이션 정리 (0) | 2023.08.17 |
JPA Auditing (0) | 2023.08.17 |