spring boot 3.3.0
java 21
기본 email profile openid 3개 scope 연결
카카오도 연결할거니까 openid 제외하고 2개만 연결
oauth client id 생성
왼쪽menu
사용자 인증정보 -> 사용자 인증정보 만들기 -> oauth client id
승인된 redirection uri 설정
생성 완료
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
'spring-boot-starter-security'의존성은 로그인 인증을 받은 후 경로를 이용할 수 있는 것. 모든 경로에 대해서 로그인인증을 받기 전까지는 로그인or기본페이지만 보임
src/main/resources/ 의 application.yml 설정
spring:
security:
oauth2:
client:
registration:
google:
client-id:
client-secret:
scope:
- email
- profile
naver:
client-id:
client-secret:
redirect-uri:
client-name: Naver
authorization-grant-type: authorization_code
scope:
- name
provider: # naver 추가로 작성
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
redis 설정
brew services start redis
redis-cli -- redis 실행
application.yml
spring:
data:
redis:
host: localhost
port: 6379
url: jdbc:redis://유저네임:비밀번호@호스트 이름:포트번호
password: 비밀번호
참고