csrf

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package csrf provides experimental CSRF token helpers for templates.

Index

Constants

View Source
const DefaultTokenKey = "X-CSRF-Token"

DefaultTokenKey is the default form/header name used by fallback tokens.

Variables

This section is empty.

Functions

func FuncMap

func FuncMap() template.FuncMap

FuncMap returns placeholders for the csrf template helper.

go-doc:funcmap

func Stage

func Stage() partial.RenderStage

Stage installs the csrf template helper from the render context.

func WithToken

func WithToken(ctx context.Context, token Token) context.Context

WithToken stores a Token on a context.

func WithTokenString

func WithTokenString(ctx context.Context, token string) context.Context

WithTokenString stores a raw token string on a context.

Types

type Token

type Token interface {
	Token(ctx context.Context) string
	Key() string
}

Token describes the CSRF token exposed to templates.

func CSRF

func CSRF(ctx ...*partial.RenderContext) Token

CSRF returns the configured token for a render context.

go-doc:sig func() github.com/donseba/go-partial/exp/csrf.Token

func FromContext

func FromContext(ctx context.Context) Token

FromContext returns the configured Token or an invalid fallback token.

Jump to

Keyboard shortcuts

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