security

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 5 Imported by: 5

Documentation

Overview

Package security is a toolkit for security check and authorization

Package security is a toolkit for security check and authorization

Package security is a toolkit for authorization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(userid, password string) (string, error)

BasicAuth creates a basic s string.

func ErrAuthType

func ErrAuthType(t TokenType) error

func RFC7617UserPass

func RFC7617UserPass(userid, password string) (string, error)

RFC7617UserPass base64 encodes a authUser-id and password per: https://tools.ietf.org/html/rfc7617#section-2

Types

type Scheme

type Scheme struct {
	Type        TokenType
	Credentials string
}

func ParseScheme

func ParseScheme(token string) Scheme

ParseScheme parses a token string into a Scheme.

func (*Scheme) String

func (ts *Scheme) String() string

type Token

type Token interface {
	json.Marshaler
	// TokenType returns the token type
	TokenType() TokenType
	// Domain returns the domain
	Domain() string
	// Subject returns the subject
	Subject() string
	// ExpiresAt returns the expiration time
	ExpiresAt() int64
	// AccessToken returns the access token
	AccessToken() string
	// Others returns the others
	Others() map[string]any
}

Token is an interface for getting token information

type TokenSerializer

type TokenSerializer interface {
	Generate(subject string) Token
	Parse(token string) (Token, error)
}

type TokenType

type TokenType int

TokenType is the type of token.

const (
	AnonymousToken TokenType = iota
	BasicToken
	BearerToken
	DigestToken
	DPoPToken
	GNAPToken
	HOBAToken
	MutualToken
	NegotiateToken
	NTLMToken
	OAuthToken
	PrivateTokenToken
	AWS4HMACSHA256Token
	SCRAMToken
	SCRAMSHA1Token
	SCRAMSHA256Token
	VAPIDToken
	InvalidToken
)

func (TokenType) String

func (i TokenType) String() string

Jump to

Keyboard shortcuts

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