File tree 1 file changed +52
-0
lines changed
src/main/kotlin/entry/dsm/gitauth/equusgithubauth/global/security/auth
1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ package entry.dsm.gitauth.equusgithubauth.global.security.auth
2
+
3
+
4
+ import entry.dsm.gitauth.equusgithubauth.domain.user.entity.User
5
+ import org.springframework.security.core.GrantedAuthority
6
+ import org.springframework.security.core.authority.SimpleGrantedAuthority
7
+ import org.springframework.security.core.userdetails.UserDetails
8
+ import org.springframework.security.oauth2.core.user.OAuth2User
9
+
10
+ class CustomOauth2UserDetails (
11
+ private val user : User ,
12
+ private val attributes : Map <String , Any >
13
+ ) : UserDetails, OAuth2User {
14
+
15
+ override fun getAttributes (): Map <String , Any > {
16
+ return attributes
17
+ }
18
+
19
+ override fun getName (): String {
20
+ return " " // OAuth2에서 getName은 필요에 맞게 처리할 수 있다
21
+ }
22
+
23
+ override fun getAuthorities (): Collection <GrantedAuthority > {
24
+ val authorities: MutableCollection <GrantedAuthority > = ArrayList ()
25
+ authorities.add(SimpleGrantedAuthority (user.role.name))
26
+ return authorities
27
+ }
28
+
29
+ override fun getPassword (): String {
30
+ return user.password
31
+ }
32
+
33
+ override fun getUsername (): String {
34
+ return user.loginId
35
+ }
36
+
37
+ override fun isAccountNonExpired (): Boolean {
38
+ return true
39
+ }
40
+
41
+ override fun isAccountNonLocked (): Boolean {
42
+ return true
43
+ }
44
+
45
+ override fun isCredentialsNonExpired (): Boolean {
46
+ return true
47
+ }
48
+
49
+ override fun isEnabled (): Boolean {
50
+ return true
51
+ }
52
+ }
You can’t perform that action at this time.
0 commit comments