These docs are for v3.0. Click to read the latest docs for v7.0.

OAuth2 state

CookieState

To configure the CookieState provider you must use the CookieStateSettings class. This class has the following form:

case class CookieStateSettings(
  cookieName: String = "OAuth2State",
  cookiePath: String = "/",
  cookieDomain: Option[String] = None,
  secureCookie: Boolean = true,
  httpOnlyCookie: Boolean = true,
  expirationTime: FiniteDuration = 5 minutes)

Property

Description

cookieName

The cookie name

cookiePath

The cookie path

cookieDomain

The cookie domain

secureCookie

Whether this cookie is secured, sent only for HTTPS requests

Note:
This should be disabled for testing on localhost without SSL, otherwise cookie couldn't be set

httpOnlyCookie

Whether this cookie is HTTP only, i.e. not accessible from client-side JavaScript code

expirationTime

State expiration. Defaults to 5 minutes which provides sufficient time to log in, but not too much. This is a balance between convenience and security

Example

oauth2StateProvider.cookieName = "OAuth2State"
oauth2StateProvider.cookiePath = "/"
oauth2StateProvider.secureCookie = false
oauth2StateProvider.httpOnlyCookie = true
oauth2StateProvider.expirationTime = 5 minutes