Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 스프링부트팔로잉
- 스프링익셉션처리
- 스프링부트팔로우취소
- WAS웹서버
- 출처 따배도
- centos도커설치
- 우분투도커설치
- 도커설치하는법
- springboot_exception_handler
- vm도커설치하는법
- 출처 메타코딩
- 출처 코딩셰프
- 파이썬sort
- 스프링구독
- 스프링부트중복예외처리
- 스프링이미지업로드
- 스프링사진업로드
- 출처 문어박사
- 서버에도커설치
- 출처 노마드코더
- 스프링부트api
- 스프링부트구독취소
- 멀티폼
- 스프링부트사진올리기
- 스프링부트
- 인스타클론
- 스프링사진
- ssh도커설치
- 스프링부트서버에사진전송
- dockerinstall
Archives
- Today
- Total
MakerHyeon
[SpringBoot] Security 네이버 로그인 본문
[SpringBoot] Security 네이버 로그인
- loginForm에 등록
<a href="/oauth2/authorization/naver">네이버 로그인</a>
- application.yml 추가
naver:
client-id: smgzHgKqnDOVexvnukON
client-secret: xqKSvPC9Ty
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 # 회원정보를 Json으로 받는데 response라는 키값으로 네이버가 리턴해줌.
- Naver provider 파일 생성
public class NaverUserInfo implements OAuth2UserInfo{
private Map<String,Object> attributes;
public NaverUserInfo(Map<String,Object> attributes){
this.attributes = attributes;
}
@Override
public String getProviderId() {
return (String) attributes.get("id");
}
@Override
public String getProvider() {
return "naver";
}
@Override
public String getEmail() {
return (String) attributes.get("email");
}
@Override
public String getName() {
return (String) attributes.get("name");
}
}
- 네이버 로그인 요청 서비스
// PrincipalOauth2UserService.java
...
else if(userRequest.getClientRegistration().getRegistrationId().equals("naver")){
oAuth2UserInfo = new NaverUserInfo((Map)oAuth2User.getAttributes().get("response"));
}
'SpringBoot > Security' 카테고리의 다른 글
[SpringSecurity] 인증 API - Remember Me 인증 (0) | 2023.04.04 |
---|---|
[SpringSecurity] Form Login 인증 (0) | 2023.04.03 |
[SpringBoot] Security 페이스북 로그인 (security facebook login) (0) | 2023.01.23 |
[SpringBoot] Security 구글 로그인 (0) | 2023.01.21 |
[SpringBoot] Security 권한 부분 설정 (0) | 2023.01.20 |
Comments