Spring-Security-5

akanana·2023년 3월 3일
0

Spring-Security

목록 보기
6/8

목표

  • 구글 OAuth 를 통해 로그인
  • Facebook OAuth 를 통해 로그인
  • Naver OAuth 를 통해 로그인
  • Kakao OAuth 를 통해 로그인

Facebook Key 등록

Meta 개발자
1 MyApps 클릭

2 앱만들기 선택 후 다음 클릭

3

3 설정-기본 설정에서 앱ID 및 앱 시크릿코드 확인

application.yml

spring:
  security:
    oauth2:
      client:
        registration:
          facebook:
            client-id: 1523566151486789
            client-secret: 1ec2e1577782b6c6cc9fa54eedbc3d51
            scope:
              - email
              - public_profile

네이버 Key 등록

네이버 개발자
1 Application 클릭

2 Application 등록

3 네이버 로그인 선택 후, 필요 정보 추가

4 서비스 URL 및 네이버 로그인 URL 등록

5 Client ID 및 Client Secret 확인

application.yml

spring:
  security:
    oauth2:
      client:
        registration:
          naver:
            client-id: WgRQvbxCC_Ff2DfXt2Pt
            client-secret: p_5nz6xGsV
            scope:
              - name
              - email
            client-name: naver
            authorization-grant-type: authorization_code
            redirect-uri: http://localhost:8080/login/oauth2/code/naver
        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

링크
1 내 어플리케이션-어플리케이션 추가

2

3. 요약정보-REST API 키: client-id 에 사용 예정

4. 플랫폼-Web에 "http://localhost:8080"추가

5. 등록하러 가기 클릭

6. 활성화 설정 및 Redirect URI "http://localhost:8080/login/oauth2/code/kakao" 추가

7. secret 키 확인 및 활성화

spring:
  security:
    oauth2:
      client:
        registration:
          kakao:
            client-id: {client-id}
            client-secret: {client-secret}
            scope:
              - profile_nickname
              - account_email
            client-name: Kakao
            authorization-grant-type: authorization_code
            redirect_uri: http://localhost:8080/login/oauth2/code/kakao
            client-authentication-method: POST
        provider:
          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

로그인 처리는 이어서 계속...

0개의 댓글