mirror of https://github.com/usbharu/Hideout.git
fix: セッション認証を廃止
This commit is contained in:
parent
ec7b01c7ce
commit
e44d0b545f
|
@ -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