token

package
v2.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const SignerAlgo = "HS256"

SignerAlgo id default algorithm used to sign JWT tokens.

Variables

This section is empty.

Functions

func CheckCsrf

func CheckCsrf(r *http.Request, fn SecretFunc) error

Types

type SecretFunc

type SecretFunc func(*Token) (string, error)

type Token

type Token struct {
	Type Type
	// contains filtered or unexported fields
}

func New

func New(tokenType Type) *Token

func Parse added in v2.7.0

func Parse(allowedTypes []Type, raw string, fn SecretFunc) (*Token, error)

func ParseRequest

func ParseRequest(allowedTypes []Type, r *http.Request, fn SecretFunc) (*Token, error)

func (*Token) Get added in v2.5.0

func (t *Token) Get(key string) string

func (*Token) Set added in v2.5.0

func (t *Token) Set(key, value string)

func (*Token) Sign

func (t *Token) Sign(secret string) (string, error)

Sign signs the token using the given secret hash and returns the string value.

func (*Token) SignExpires

func (t *Token) SignExpires(secret string, exp int64) (string, error)

Sign signs the token using the given secret hash with an expiration date.

type Type added in v2.7.0

type Type string
const (
	UserToken       Type = "user" // user token (exp cli)
	SessToken       Type = "sess" // session token (ui token requires csrf check)
	HookToken       Type = "hook" // repo hook token
	CsrfToken       Type = "csrf"
	AgentToken      Type = "agent"
	OAuthStateToken Type = "oauth-state"
)

Jump to

Keyboard shortcuts

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