application

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FormTokenName is used to define HTML input field parameter name.
	FormTokenName = "csrftoken"
	// HeaderTokenName is used to define the header field name which can contain the token.
	HeaderTokenName = "Csrf-Token" //nolint:gosec // false positive
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service interface {
	Generate(session *web.Session) string
	IsValid(request *web.Request) bool
	IsValidPost(request *web.Request) bool
	IsValidHeader(request *web.Request) bool
}

Service is interface to define usage of service responsible for creating and validation csrf token.

type ServiceImpl

type ServiceImpl struct {
	// contains filtered or unexported fields
}

ServiceImpl is actual implementation of Service interface

func (*ServiceImpl) Generate

func (s *ServiceImpl) Generate(session *web.Session) string

Generate creates csrf token depending on user session ID and time. It uses AES standard for encrypting data.

func (*ServiceImpl) Inject

func (s *ServiceImpl) Inject(l flamingo.Logger, cfg *struct {
	Secret string  `inject:"config:csrf.secret"`
	TTL    float64 `inject:"config:csrf.ttl"`
})

Inject dependencies

func (*ServiceImpl) IsValid

func (s *ServiceImpl) IsValid(request *web.Request) bool

IsValid validates csrf token from POST request. Deprecated - use IsVaildPost instead. It uses AES standard for decrypting data. Session ID from csrf token must be the one in the request and token life time must be valid.

func (*ServiceImpl) IsValidHeader

func (s *ServiceImpl) IsValidHeader(request *web.Request) bool

IsValidHeader validates csrf token in request header field. It uses AES standard for decrypting data. Session ID from csrf token must be the one in the request and token life time must be valid.

func (*ServiceImpl) IsValidPost

func (s *ServiceImpl) IsValidPost(request *web.Request) bool

IsValidPost validates csrf token from POST request. It uses AES standard for decrypting data. Session ID from csrf token must be the one in the request and token life time must be valid.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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