Skip to content

Commit 9416b84

Browse files
committed
feat(oauth): OAuth2User 클래스에 OAuthProvider를 필드로 추가한 CustomOAuth2User 추가
1 parent 8a1adfb commit 9416b84

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.somemore.global.auth.oauth.domain;
2+
3+
import lombok.Getter;
4+
import lombok.RequiredArgsConstructor;
5+
import org.springframework.security.core.GrantedAuthority;
6+
import org.springframework.security.oauth2.core.user.OAuth2User;
7+
8+
import java.util.Collection;
9+
import java.util.Map;
10+
11+
@RequiredArgsConstructor
12+
@Getter
13+
public class CustomOAuth2User implements OAuth2User {
14+
15+
private final OAuth2User oAuth2User;
16+
private final OAuthProvider provider;
17+
18+
@Override
19+
public Map<String, Object> getAttributes() {
20+
return oAuth2User.getAttributes();
21+
}
22+
23+
@Override
24+
public Collection<? extends GrantedAuthority> getAuthorities() {
25+
return oAuth2User.getAuthorities();
26+
}
27+
28+
@Override
29+
public String getName() {
30+
return oAuth2User.getName();
31+
}
32+
33+
public static CustomOAuth2User of(OAuth2User oAuth2User, OAuthProvider oAuthProvider) {
34+
return new CustomOAuth2User(oAuth2User, oAuthProvider);
35+
}
36+
}

0 commit comments

Comments
 (0)