Skip to content
Playground(another site)

bynk.actor.signed_cookie_write_directly

Error A cookie record's typed write names the session cookie that a SignedCookie actor consumes.

A SignedCookie actor's session cookie is minted by Actor.issue(identity), which signs it with the actor's key, and removed by Actor.expire(), and the CSRF check keys off that actor. A cookie record's R.field.cookie(v) or R.field.expire() whose field is read under the session cookie's name would write or clear the credential without any of that, so it is refused. Keep the session cookie out of the record and use the actor's own members.

Example

type Prefs = {
@name("__Host-session") session: Option[String],
theme: Option[String],
}
Ok("x").withCookie(Prefs.session.cookie("forged")) // ✗ the session cookie
Ok("x").withCookie(Prefs.theme.cookie("dark")) // ✓ another cookie

In the Book

See also

  • Every code in its category, Actors, on the diagnostic index.
  • bynk explain bynk.actor.signed_cookie_write_directly shows the same from the installed toolchain, without a network.