-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from TinU-Official/issue63/refresh-token-logic…
…-feat Issue63/refresh token logic feat
- Loading branch information
Showing
15 changed files
with
305 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/tinuproject/tinu/domain/entity/RefreshToken.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.tinuproject.tinu.domain.entity | ||
|
||
import com.tinuproject.tinu.domain.entity.base.BaseEntity | ||
import jakarta.persistence.* | ||
import java.util.* | ||
|
||
@Entity | ||
class RefreshToken( | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
var id : Long?= null, | ||
|
||
@Column(unique = true) | ||
var userId : UUID, | ||
|
||
@Column(unique = true) | ||
var token : String | ||
){ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...main/kotlin/com/tinuproject/tinu/domain/socialmember/repository/SocialMemberRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.tinuproject.tinu.domain.socialmember.repository | ||
|
||
import com.tinuproject.tinu.domain.entity.SocialMember | ||
import org.springframework.data.repository.CrudRepository | ||
import org.springframework.stereotype.Repository | ||
import java.util.* | ||
|
||
@Repository | ||
interface SocialMemberRepository:CrudRepository<SocialMember, Long> { | ||
fun findByUserId(userId : UUID) : SocialMember? | ||
|
||
fun findByProviderId(providerId : String) : SocialMember? | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/kotlin/com/tinuproject/tinu/domain/socialmember/service/SocialMemberService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.tinuproject.tinu.domain.socialmember.service | ||
|
||
interface SocialMemberService { | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/tinuproject/tinu/security/RefreshTokenRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.tinuproject.tinu.security | ||
|
||
import com.tinuproject.tinu.domain.entity.RefreshToken | ||
import jakarta.persistence.ManyToOne | ||
import jakarta.transaction.Transactional | ||
import org.springframework.data.jpa.repository.Modifying | ||
import org.springframework.data.repository.CrudRepository | ||
import org.springframework.stereotype.Repository | ||
import java.util.* | ||
|
||
@Repository | ||
interface RefreshTokenRepository:CrudRepository<RefreshToken, Long> { | ||
|
||
fun findByUserId(userId : UUID) : RefreshToken | ||
|
||
@Transactional | ||
@Modifying | ||
fun deleteByUserId(userId : UUID) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/tinuproject/tinu/security/oauth2/dto/KakaoUserInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.tinuproject.tinu.security.oauth2.dto | ||
|
||
class KakaoUserInfo( | ||
private var attributes: Map<String, Any> | ||
) :OAuth2UserInfoDto { | ||
override fun getProviderId(): String { | ||
return attributes["id"].toString() | ||
} | ||
|
||
override fun getProvider(): String { | ||
return "kakao" | ||
} | ||
|
||
override fun getName() :String{ | ||
|
||
return (attributes["properties"] as Map<*, *>)["nickname"].toString() | ||
|
||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/com/tinuproject/tinu/security/oauth2/dto/NaverUserInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.tinuproject.tinu.security.oauth2.dto | ||
|
||
class NaverUserInfo( | ||
private var attributes: Map<String, Any> | ||
):OAuth2UserInfoDto { | ||
override fun getProviderId(): String { | ||
return attributes["id"].toString() | ||
} | ||
|
||
override fun getProvider(): String { | ||
return "naver" | ||
} | ||
|
||
override fun getName() : String { | ||
return attributes["name"].toString() | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/com/tinuproject/tinu/security/oauth2/dto/OAuth2UserInfoDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.tinuproject.tinu.security.oauth2.dto | ||
|
||
interface OAuth2UserInfoDto { | ||
fun getProviderId() : String | ||
|
||
fun getProvider() : String | ||
|
||
fun getName() : String | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/tinuproject/tinu/security/oauth2/dto/UserInfoDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.tinuproject.tinu.security.oauth2.dto | ||
|
||
import java.util.* | ||
|
||
class UserInfoDto ( | ||
var uuid : UUID, | ||
|
||
var name : String, | ||
|
||
var providerId : String, | ||
|
||
var provider : String | ||
) { | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/com/tinuproject/tinu/security/oauth2/handler/OAuthLoginFailureHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.tinuproject.tinu.security.oauth2.handler | ||
|
||
import jakarta.servlet.ServletException | ||
import jakarta.servlet.http.HttpServletRequest | ||
import jakarta.servlet.http.HttpServletResponse | ||
import org.slf4j.Logger | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.security.core.AuthenticationException | ||
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler | ||
import org.springframework.stereotype.Component | ||
import java.io.IOException | ||
|
||
@Component | ||
class OAuthLoginFailureHandler(): SimpleUrlAuthenticationFailureHandler() { | ||
var log : Logger = LoggerFactory.getLogger(this::class.java) | ||
|
||
@Throws(IOException::class, ServletException::class) | ||
override fun onAuthenticationFailure( | ||
request: HttpServletRequest?, | ||
response: HttpServletResponse?, | ||
exception: AuthenticationException | ||
) { | ||
log.error("LOGIN FAILED : {}", exception.message) | ||
super.onAuthenticationFailure(request, response, exception) | ||
} | ||
} |
Oops, something went wrong.