CodeSampleX

示例

plug 1.20.3: Configure Plug.Session cookie storage, signing salts, 64-byte secret key constraints, and lazy cookie serialization

已验证示例 — hex plug 1.20.3: Configure Plug.Session cookie storage, signing salts, 64-byte secret key constraints, and lazy cookie serialization. contract 在…

sha256:3ef390aae7cf632653e7ba065c15143a68dcd2829bcc012a4bf60960c4dcda4b

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
2
构建过它的签名密钥
2
声明的环境 elixir linux x64 elixir elixir mix

验证运行环境

环境 契约 阶段 运行日期
elixir 1 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:PASS · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · hex@1
2026-08-17
elixir 1 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:PASS · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · hex@1
2026-08-18

案例

HOW
目标
Configure Plug.Session cookie storage, signing salts, 64-byte secret key constraints, and lazy cookie serialization
符号
  • Plug.Session
  • Plug.Session.COOKIE
  • Plug.Conn.fetch_session
  • Plug.Conn.put_session
  • Plug.Conn.get_session
  • Plug.Conn.configure_session
环境
elixir
创建时间
2026-08-17T10:30:17Z

契约

  1. assert Plug.Session.init/1 enforces :signing_salt for cookie storage at initialization but defers :secret_key_base validation until runtime, where omitting it or providing fewer than 64 bytes raises ArgumentError only when fetching or writing cookies
  2. assert calling get_session/2 before fetch_session/2 raises ArgumentError stating the session is not fetched
  3. assert read-only session inspection never emits a set-cookie response header, while session mutations register a before_send callback to emit signed cookie headers with HttpOnly and path=/
  4. assert tampered or forged incoming cookie signatures are silently dropped with an empty session map rather than raising a runtime decoding error
  5. assert configuring :encryption_salt upgrades session payload handling from base64-encoded signed plaintext to AES-GCM ciphertext
  6. assert configure_session(conn, drop: true) on an active session emits a set-cookie header with max-age=0 to expire the cookie on the client

文件

  • NOTES.md
  • csx.json
  • lib/csx_plug_session/session_pipeline.ex
  • mix.exs
  • mix.lock
  • test/contract_test.exs
  • test/test_helper.exs

下载源代码构件 (tar.gz)

原始种子者

csx-seed