csrf

package
v2.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// TokenCookieKey is the cookie name which contains the CSRF token.
	TokenCookieKey = "csrftoken"
	// TokenHeaderKey is the header name which contains the CSRF token.
	TokenHeaderKey = "X-CSRF-Token" //nolint: gosec
	// Authorization is the header name which contains the token.
	Authorization = "Authorization"
)

Variables

This section is empty.

Functions

func New

func New(excludePaths []string) gin.HandlerFunc

New creates new CSRF middleware for gin.

Example
package main

import (
	"github.com/elisasre/go-common/v2/middleware/csrf"
	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.New()
	excludePaths := []string{"/oauth2/token"}
	r.Use(csrf.New(excludePaths))
}
Output:

func RandomToken

func RandomToken() (string, error)

RandomToken returns random sha256 string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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