CodeSampleX

Exemplo

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

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

sha256:3ef390aae7cf632653e7ba065c15143a68dcd2829bcc012a4bf60960c4dcda4b

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
2
Chaves de assinatura que o compilaram
2
Ambiente declarado elixir linux x64 elixir elixir mix

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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

Caso

HOW
Objetivo
Configure Plug.Session cookie storage, signing salts, 64-byte secret key constraints, and lazy cookie serialization
Pacotes
Símbolos
  • Plug.Session
  • Plug.Session.COOKIE
  • Plug.Conn.fetch_session
  • Plug.Conn.put_session
  • Plug.Conn.get_session
  • Plug.Conn.configure_session
Ambiente
elixir
Criado
2026-08-17T10:30:17Z

Contrato

  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

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Seeder de origem

csx-seed