Permalink
Browse files

Updated default session cookie name to be the server name

Updated max-age on session cookies to default to one year
  • Loading branch information...
darkfrog26 committed Dec 5, 2018
1 parent d3a30c4 commit 18eae0259ff82d8d4a0a6587db9208a20acb9196
@@ -1,6 +1,7 @@
package io.youi.server
import java.io.File
import java.util.concurrent.TimeUnit
import io.youi.http.cookie.SameSite
import profig.Profig
@@ -11,7 +12,7 @@ class ServerConfig(server: Server) {
private val config = Profig("session").as[SessionConfig]
val name: Var[String] = Var(config.name)
val maxAge: Var[Option[Long]] = Var(config.maxAge)
val maxAge: Var[Long] = Var(config.maxAge)
val domain: Var[Option[String]] = Var(config.domain)
val secure: Var[Boolean] = Var(config.secure)
val httpOnly: Var[Boolean] = Var(config.httpOnly)
@@ -20,6 +21,13 @@ class ServerConfig(server: Server) {
case "lax" => SameSite.Lax
case "strict" => SameSite.Strict
})
case class SessionConfig(name: String = server.getClass.getSimpleName.replaceAllLiterally("$", ""),
maxAge: Long = TimeUnit.DAYS.toSeconds(365L),
domain: Option[String] = None,
secure: Boolean = false,
httpOnly: Boolean = true,
sameSite: String = "strict")
}
/**
@@ -105,11 +113,4 @@ case class HttpsServerListener(host: String = "127.0.0.1",
case class KeyStore(path: String = "keystore.jks", password: String = "password") {
lazy val location: File = new File(path)
}
case class SessionConfig(name: String = "JSESSIONID",
maxAge: Option[Long] = None,
domain: Option[String] = None,
secure: Boolean = false,
httpOnly: Boolean = true,
sameSite: String = "strict")
}
@@ -36,7 +36,7 @@ object SessionStore {
val cookie = ResponseCookie(
name = session.name,
value = id,
maxAge = session.maxAge,
maxAge = if (session.maxAge() == 0L) None else Some(session.maxAge),
domain = session.domain,
secure = session.secure,
httpOnly = session.httpOnly,

0 comments on commit 18eae02

Please sign in to comment.