-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
98 additions
and
18 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...rity/jwt/ConfigurationPropertiesConfig.kt → ...l/config/ConfigurationPropertiesConfig.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
15 changes: 0 additions & 15 deletions
15
src/main/kotlin/team/sfe/server/global/filter/FilterConfig.kt
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
src/main/kotlin/team/sfe/server/global/filter/JwtFilter.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,36 @@ | ||
package team.sfe.server.global.filter | ||
|
||
import jakarta.servlet.FilterChain | ||
import jakarta.servlet.http.HttpServletRequest | ||
import jakarta.servlet.http.HttpServletResponse | ||
import org.springframework.web.filter.OncePerRequestFilter | ||
import team.sfe.server.global.security.jwt.JwtConstant.HEADER | ||
import team.sfe.server.global.security.jwt.JwtConstant.PREFIX | ||
import team.sfe.server.global.security.jwt.JwtParser | ||
|
||
class JwtFilter( | ||
private val jwtParser: JwtParser | ||
) : OncePerRequestFilter() { | ||
|
||
override fun doFilterInternal( | ||
request: HttpServletRequest, | ||
response: HttpServletResponse, | ||
filterChain: FilterChain | ||
) { | ||
val token = getToken(request) | ||
token?.let { | ||
TODO() | ||
} | ||
filterChain.doFilter(request, response) | ||
} | ||
|
||
private fun getToken(request: HttpServletRequest): String? { | ||
val token = request.getHeader(HEADER) | ||
|
||
return if (token.isNotEmpty() && token.startsWith(PREFIX)) { | ||
token.substring(PREFIX.length) | ||
} else { | ||
null | ||
} | ||
} | ||
} |
20 changes: 18 additions & 2 deletions
20
src/main/kotlin/team/sfe/server/global/security/SecurityConfig.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
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/team/sfe/server/global/security/auth/AuthDetails.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 team.sfe.server.global.security.auth | ||
|
||
import org.springframework.security.core.GrantedAuthority | ||
import org.springframework.security.core.authority.SimpleGrantedAuthority | ||
import org.springframework.security.core.userdetails.UserDetails | ||
import team.sfe.server.domain.user.domain.type.Authority | ||
|
||
class AuthDetails( | ||
private val userId: Long, | ||
private val authority: Authority | ||
) : UserDetails { | ||
override fun getAuthorities(): MutableCollection<out GrantedAuthority> = | ||
mutableListOf(SimpleGrantedAuthority(authority.name)) | ||
|
||
override fun getPassword(): String? = null | ||
|
||
override fun getUsername(): String = userId.toString() | ||
|
||
override fun isAccountNonExpired(): Boolean = true | ||
|
||
override fun isAccountNonLocked(): Boolean = true | ||
|
||
override fun isCredentialsNonExpired(): Boolean = true | ||
|
||
override fun isEnabled(): Boolean = true | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/team/sfe/server/global/security/auth/AuthDetailsService.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,12 @@ | ||
package team.sfe.server.global.security.auth | ||
|
||
import org.springframework.security.core.userdetails.UserDetails | ||
import org.springframework.security.core.userdetails.UserDetailsService | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class AuthDetailsService : UserDetailsService { | ||
override fun loadUserByUsername(username: String?): UserDetails { | ||
TODO("Not yet implemented") | ||
} | ||
} |
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