mirror of https://github.com/usbharu/Hideout.git
fix: セッション認証を廃止
This commit is contained in:
parent
08f4d38712
commit
39be6647e0
|
@ -1,11 +1,10 @@
|
|||
package dev.usbharu.hideout.plugins
|
||||
|
||||
import dev.usbharu.hideout.service.IUserAuthService
|
||||
import dev.usbharu.hideout.service.UserService
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.auth.*
|
||||
import io.ktor.server.sessions.*
|
||||
import kotlin.time.Duration.Companion.days
|
||||
import kotlin.collections.set
|
||||
|
||||
data class UserSession(val username: String) : Principal
|
||||
|
||||
|
@ -14,11 +13,15 @@ const val tokenAuth = "token-auth"
|
|||
fun Application.configureSecurity(userAuthService: IUserAuthService) {
|
||||
install(Authentication) {
|
||||
bearer(tokenAuth) {
|
||||
authenticate {
|
||||
bearerTokenCredential ->
|
||||
authenticate { bearerTokenCredential ->
|
||||
UserIdPrincipal(bearerTokenCredential.token)
|
||||
}
|
||||
skipWhen { true }
|
||||
}
|
||||
}
|
||||
// install(Sessions) {
|
||||
// cookie<UserSession>("MY_SESSION") {
|
||||
// cookie.extensions["SameSite"] = "lax"
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ fun Application.login(){
|
|||
post("/login") {
|
||||
println("aaaaaaaaaaaaaaaaaaaaa")
|
||||
val principal = call.principal<UserIdPrincipal>()
|
||||
call.sessions.set(UserSession(principal!!.name))
|
||||
call.respondRedirect("/users/${principal.name}")
|
||||
// call.sessions.set(UserSession(principal!!.name))
|
||||
call.respondRedirect("/users/${principal!!.name}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue