From 39be6647e0a7f4eb339c3bcb8503527fbf4b1344 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 24 Mar 2023 16:07:33 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=82=BB=E3=83=83=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E8=AA=8D=E8=A8=BC=E3=82=92=E5=BB=83=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/dev/usbharu/hideout/plugins/Security.kt | 13 ++++++++----- .../dev/usbharu/hideout/routing/LoginRouting.kt | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/Security.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/Security.kt index 9a195f3c..94485569 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/Security.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/Security.kt @@ -1,24 +1,27 @@ 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 const val tokenAuth = "token-auth" fun Application.configureSecurity(userAuthService: IUserAuthService) { - install(Authentication){ + install(Authentication) { bearer(tokenAuth) { - authenticate { - bearerTokenCredential -> + authenticate { bearerTokenCredential -> UserIdPrincipal(bearerTokenCredential.token) } skipWhen { true } } } +// install(Sessions) { +// cookie("MY_SESSION") { +// cookie.extensions["SameSite"] = "lax" +// } +// } } diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/LoginRouting.kt b/src/main/kotlin/dev/usbharu/hideout/routing/LoginRouting.kt index ad23228f..f3e44b7d 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/LoginRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/LoginRouting.kt @@ -15,8 +15,8 @@ fun Application.login(){ post("/login") { println("aaaaaaaaaaaaaaaaaaaaa") val principal = call.principal() - call.sessions.set(UserSession(principal!!.name)) - call.respondRedirect("/users/${principal.name}") +// call.sessions.set(UserSession(principal!!.name)) + call.respondRedirect("/users/${principal!!.name}") } }