sessionwire

package
v0.1.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sessionwire holds shared LIP session carrier keys and decode helpers for frontends. Security decisions stay in core; adapters only lift protocol-legal fields into lipapi.SessionRef.

Index

Constants

View Source
const (
	HeaderAuthoritativeSessionID = lipsdk.HeaderSessionID
	HeaderResumeToken            = lipsdk.HeaderResumeToken
	HeaderALegID                 = lipsdk.HeaderALegID
	HeaderSessionHint            = lipsdk.HeaderSessionHint
	// Metadata keys for JSON request bodies (OpenAI-style metadata maps).
	MetaKeyAuthoritativeSessionID = "lip_session_id"
	MetaKeyResumeToken            = "lip_resume_token"
)

LIP-controlled HTTP carriers for secure-session resume (proxy-issued values round-tripped by clients).

Variables

This section is empty.

Functions

func ApplyAuthoritativeHeaders

func ApplyAuthoritativeHeaders(ref *lipapi.SessionRef, h http.Header)

ApplyAuthoritativeHeaders merges LIP session headers into ref when present (trimmed). Caller supplies ref; zero fields are left unchanged when a header is absent.

func ApplyAuthoritativeHeadersNamed

func ApplyAuthoritativeHeadersNamed(ref *lipapi.SessionRef, h http.Header, sessionID, resumeToken []string)

ApplyAuthoritativeHeadersNamed merges session-id and resume-token from the given header names. Empty name lists use HeaderAuthoritativeSessionID and HeaderResumeToken.

func ApplyMetadata

func ApplyMetadata(ref *lipapi.SessionRef, meta map[string]string)

ApplyMetadata merges string metadata entries into ref when keys are present (trimmed). Headers should be applied after metadata if headers must win on conflict.

func BuildSessionInput

func BuildSessionInput(h http.Header, meta map[string]string, opts SessionInputOptions) (largebody.SessionInput, error)

BuildSessionInput builds an exact bounded largebody.SessionInput from HTTP headers and body metadata, enforcing:

  • header/body/session/resume/client-session precedence (headers win over body metadata);
  • rejection of body-carried LIP session metadata when RejectBodyMetadata is true (Requirements 14.2, 17.5);
  • sensitive resume token wrapping via largebody.SensitiveString (Requirements 14.1, 22);
  • exact scalar bounds on all session fields under lipapi envelope caps and semantic-fact budget.

func HTTPStatusForSessionDenial

func HTTPStatusForSessionDenial(code lipapi.SessionDenialCode) int

HTTPStatusForSessionDenial maps stable lipapi.SessionDenialCode values to HTTP status codes for frontend adapters (protocol-neutral transport semantics).

func HasSessionMetadata

func HasSessionMetadata(meta map[string]string) bool

HasSessionMetadata reports whether meta contains any LIP-controlled session keys.

func ValidateMetadata

func ValidateMetadata(meta map[string]string) error

ValidateMetadata checks LIP-controlled session metadata carriers before callers copy them into the canonical session reference.

func WithoutSensitiveToken

func WithoutSensitiveToken(s, rawToken string) string

WithoutSensitiveToken replaces exact rawToken substrings in s for log-safe strings.

func WriteResponseCarriers

func WriteResponseCarriers(w http.ResponseWriter, call *lipapi.Call)

WriteResponseCarriers sets LIP session response headers from call.Session when fields are non-empty.

func WriteSessionResponseCarrier

func WriteSessionResponseCarrier(w http.ResponseWriter, carrier largebody.SessionResponseCarrier)

WriteSessionResponseCarrier sets LIP session response headers from largebody.SessionResponseCarrier when fields are non-empty. It reveals the sensitive resume token only into the designated response header at the frontend transport boundary (Requirements 14.6, 18.2, 22.3).

func WriteSessionResponseCarrierHeaders

func WriteSessionResponseCarrierHeaders(h http.Header, carrier largebody.SessionResponseCarrier)

WriteSessionResponseCarrierHeaders sets LIP session response headers on h from carrier when fields are non-empty.

Types

type SessionInputOptions

type SessionInputOptions struct {
	HeaderAliases      lipsdk.HTTPHeaders
	RejectBodyMetadata bool
	MaxFactBytes       int64
}

SessionInputOptions parameterizes SessionInput extraction for a frontend profile.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL