-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomOAuth2User.java
More file actions
30 lines (24 loc) · 1.06 KB
/
CustomOAuth2User.java
File metadata and controls
30 lines (24 loc) · 1.06 KB
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
package bitnagil.bitnagil_backend.auth.kakao.domain;
import java.util.Collection;
import java.util.Map;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
import bitnagil.bitnagil_backend.user.domain.enums.Role;
import lombok.Getter;
/**
* OAuth2 로그인 이후 인증된 사용자 정보를 담는 커스텀 OAuth2 사용자 클래스입니다.
*
* Spring Security의 {@link DefaultOAuth2User}를 확장하여,
* 기본 OAuth2 사용자 정보 외에도 애플리케이션 도메인에서 사용하는 `userId`와 `userRole`을 추가로 포함합니다.
*/
@Getter
public class CustomOAuth2User extends DefaultOAuth2User {
private final Long userId;
private final Role userRole;
public CustomOAuth2User(Collection<? extends GrantedAuthority> authorities,
Map<String, Object> attributes, String nameAttributeKey, Long userId, Role userRole) {
super(authorities, attributes, nameAttributeKey);
this.userId = userId;
this.userRole = userRole;
}
}