auth

package
v0.3.20 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultSignMethod = jwt.SigningMethodRS256
)

Functions

This section is empty.

Types

type Auth

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

func NewAuth

func NewAuth(secretKey []byte) *Auth

NewAuth returns a new *Auth

func NewAuthWithDefault

func NewAuthWithDefault() *Auth

NewAuthWithDefault returns a new *Auth with empty secret key

func (*Auth) Parse

func (a *Auth) Parse(tokenString string, in interface{}) error

Parse parses the payload from the token, it verifies the signature

func (*Auth) ParseUnverified

func (a *Auth) ParseUnverified(tokenString string, in interface{}) error

ParseUnverified parses the payload from the token, it does not verify the signature

func (*Auth) Sign

func (a *Auth) Sign() (string, error)

Sign signs with the default method and claims

func (*Auth) SignWithMethodAndClaims

func (a *Auth) SignWithMethodAndClaims(method jwt.SigningMethod, claims jwt.MapClaims, ef EncodeFunc) (string, error)

SignWithMethodAndClaims signs with the given method and claims

type EncodeFunc

type EncodeFunc func(*Token, []byte) (string, error)

func NewGZIPEncodeFunc

func NewGZIPEncodeFunc() EncodeFunc

NewGZIPEncodeFunc returns a new EncodeFunc with gzip compression, it only compresses the payload

type Parser

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

func NewParser

func NewParser(useJSONNumber bool) *Parser

NewParser returns a new *Parser

func NewParserWithDefault

func NewParserWithDefault() *Parser

NewParserWithDefault returns a new *Parser with default options

func (*Parser) Parse

func (p *Parser) Parse(tokenString string, key []byte) (*Token, error)

Parse parses the token string and verifies the signature

func (*Parser) ParseUnverified

func (p *Parser) ParseUnverified(tokenString string) (*Token, error)

ParseUnverified parses the token string without verifying the signature

type Token

type Token struct {
	Raw       string
	Method    jwt.SigningMethod
	Header    map[string]string
	Claims    jwt.MapClaims
	Signature []byte
	Valid     bool
}

func NewToken

func NewToken(method jwt.SigningMethod) *Token

NewToken returns a new *Token

func NewTokenWithClaims

func NewTokenWithClaims(method jwt.SigningMethod, claims jwt.MapClaims) *Token

NewTokenWithClaims returns a new *Token with the specified signing method and claims

func NewTokenWithRawString

func NewTokenWithRawString(raw string) *Token

NewTokenWithRawString returns a new *Token with the specified raw string

func (*Token) EncodeSegment

func (t *Token) EncodeSegment(seg []byte, ef EncodeFunc) (string, error)

EncodeSegment encodes a JWT segment, this is the place that the EncodeFunc are applied.

func (*Token) SignedString

func (t *Token) SignedString(key interface{}, ef EncodeFunc) (string, error)

SignedString creates and returns a complete, signed JWT.

func (*Token) SigningString

func (t *Token) SigningString(ef EncodeFunc) (string, error)

SigningString generates the signing string

Jump to

Keyboard shortcuts

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