token

package
v5.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 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

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

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

func (*Token) Set

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

type Type string
const (
	UserToken       Type = "user"       // user token (exp cli) - deprecated, use AccessToken
	SessToken       Type = "sess"       // session token (ui token requires csrf check)
	HookToken       Type = "hook"       // repo hook token
	CsrfToken       Type = "csrf"       // CSRF protection token
	AgentToken      Type = "agent"      // agent authentication token
	AutoscalerToken Type = "autoscaler" // autoscaler authentication token
	OAuthStateToken Type = "oauth-state"
	AccessToken     Type = "access" // personal access token with scopes
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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