Documentation
¶
Index ¶
- Variables
- func BuildClearOidcStateCookieString(secure bool) string
- func BuildClearTokenCookieStringsFor(secure bool) []string
- func BuildOidcStateCookieString(value string, maxAgeInSeconds int, secure bool) string
- func BuildTokenCookieStringFor(maxAgeInSeconds int, token string, secure bool) []string
- func ClearTokenCookie(w http.ResponseWriter, r *http.Request)
- func GetTokenCookie(r *http.Request) (string, error)
- func GetTokenCookieFromHeader(cookieHeader string) (string, error)
- func SecureCookieFromContext(ctx context.Context) bool
- func SecureCookieFromRequest(r *http.Request) bool
- type SecureCookieContextKey
Constants ¶
This section is empty.
Variables ¶
var ( TokenCookieName = "__Host-token" // #nosec G101: cookie name label, not a credential InsecureTokenCookieName = "token" // #nosec G101: cookie name label, not a credential OidcStateCookieName = "oidc_state" )
Functions ¶
func BuildClearOidcStateCookieString ¶
BuildClearOidcStateCookieString builds a Set-Cookie header string to clear the OIDC state cookie.
func BuildClearTokenCookieStringsFor ¶
BuildClearTokenCookieStringsFor builds Set-Cookie header strings to clear token cookies matching the current request security context. Secure contexts also clear the HTTP fallback cookie so stale sessions from older releases are flushed instead of being re-presented forever.
func BuildOidcStateCookieString ¶
BuildOidcStateCookieString builds a Set-Cookie header string for the OIDC state cookie.
func BuildTokenCookieStringFor ¶
BuildTokenCookieStringFor builds Set-Cookie header strings matching the current request security context. Compact browser tokens use one cookie; legacy oversized tokens are chunked for upgrade compatibility. Unused chunk slots are cleared so stale legacy chunks cannot corrupt reassembly. Callers must pass the trusted secure flag from SecureCookieFromContext / SecureCookieFromRequest so the cookie name (__Host-token vs. token) round-trips correctly behind HTTPS reverse proxies.
func ClearTokenCookie ¶
func ClearTokenCookie(w http.ResponseWriter, r *http.Request)
func GetTokenCookieFromHeader ¶ added in v2.10.0
func SecureCookieFromContext ¶
SecureCookieFromContext returns the secure-cookie decision that router middleware derived from TLS or trusted proxy headers.
func SecureCookieFromRequest ¶
SecureCookieFromRequest returns true when the request was made over TLS or router middleware marked it as forwarded from HTTPS by a trusted proxy.
Types ¶
type SecureCookieContextKey ¶ added in v2.7.0
type SecureCookieContextKey struct{}
SecureCookieContextKey is the context key under which router middleware records its trusted secure-cookie decision (a bool derived from TLS or trusted proxy headers).