types

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package types defines common types and constants used across the session package.

Index

Constants

View Source
const (
	// SCAuthCookieName is the cookie name of the Secure Cookie
	SCAuthCookieName SCKey = "auth"

	// SCSessionID is the key for storing SessionID in Secure Cookie
	SCSessionID SCKey = "sessionID"

	// SCSameSiteStrict is a key representing sameSiteStrict cookie setting
	SCSameSiteStrict SCKey = "sameSiteStrict"

	// STCookieName is the cookie name of the Secure Token Cookie
	STCookieName = "XSRF-TOKEN"

	// STHeaderName is the header name of the Secure Token Cookie
	STHeaderName = "X-XSRF-TOKEN"

	// STSessionID is the key used in store sessionID in Secure Token Cookie
	STSessionID STKey = "sessionid"

	// STTokenExpiration is the key used to store the cookie expiration in the Secure Token Cookie
	STTokenExpiration STKey = "expiration"

	// XSRFCookieLife is constant controlling XSRF Cookie expiration
	XSRFCookieLife = time.Hour

	// XSRFReWriteWindow controls rewriting xsrf cookie token if it expires within duration
	XSRFReWriteWindow = 30 * time.Minute

	// CTXSessionID is the key for storing SessionID in context
	CTXSessionID CTXKey = "sessionID"
)

Variables

View Source
var SafeMethods = methods([]string{"GET", "HEAD", "OPTIONS", "TRACE"})

SafeMethods are Idempotent methods as defined by RFC7231 section 4.2.2.

Functions

func SessionIDFromCtx

func SessionIDFromCtx(ctx context.Context) ccc.UUID

SessionIDFromCtx returns the sessionID from the request context

func SessionIDFromRequest

func SessionIDFromRequest(r *http.Request) ccc.UUID

SessionIDFromRequest returns the sessionID from the request

func ValidSessionID

func ValidSessionID(sessionID string) (ccc.UUID, bool)

ValidSessionID checks that the sessionID is a valid uuid

Types

type CTXKey

type CTXKey string

CTXKey is a type for storing values in the request context

type SCKey

type SCKey string

SCKey is a type for storing values in the session cookie

type STKey

type STKey string

STKey is a type for storing values in the secure token cookie

Jump to

Keyboard shortcuts

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