authentication

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticate

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

func New

func New(opt ...Option) (*Authenticate, error)

func (*Authenticate) Generate

func (a *Authenticate) Generate(opts ...TokenOption) (*Token, error)

func (*Authenticate) Inspect

func (a *Authenticate) Inspect(signedToken []byte) (*User, error)

func (*Authenticate) InspectWithJwk

func (a *Authenticate) InspectWithJwk(signedToken []byte) (*User, error)

func (*Authenticate) Jwks

func (a *Authenticate) Jwks() ([]byte, error)

type JwkType

type JwkType int
const (
	JwkTypeJson JwkType = iota + 1
	JwkTypePem
)

type Option

type Option func(*Options)

func WithJwk

func WithJwk(data []byte, jwkType JwkType) Option

func WithRsaPrivateKey

func WithRsaPrivateKey(key *rsa.PrivateKey) Option

func WithRsaPrivateKeyBytes

func WithRsaPrivateKeyBytes(privateKeyBytes []byte) Option

func WithRsaPublic

func WithRsaPublic(key *rsa.PublicKey) Option

func WithRsaPublicKeyBytes

func WithRsaPublicKeyBytes(publicKeyBytes []byte) Option

type Options

type Options struct {
	RsaPublicKeyBytes []byte
	// contains filtered or unexported fields
}

Options .

type Token

type Token struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token,omitempty"`
	Exp          time.Time `json:"exp,omitempty"`
	Iat          time.Time `json:"iat,omitempty"`
	Iss          string    `json:"iss,omitempty"`
}

type TokenOption

type TokenOption func(options *TokenOptions)

func WithExpiration

func WithExpiration(expiration time.Time) TokenOption

func WithIssuer

func WithIssuer(issuer string) TokenOption

func WithMetadata

func WithMetadata(metadata map[string]any) TokenOption

func WithSubject

func WithSubject(sub string) TokenOption

type TokenOptions

type TokenOptions struct {
	Metadata map[string]any
	// contains filtered or unexported fields
}

TokenOptions .

func NewGenerateTokenOptions

func NewGenerateTokenOptions(opts ...TokenOption) TokenOptions

type User

type User struct {
	ID       string                 `json:"id"`
	Metadata map[string]interface{} `json:"metadata"`
}

Jump to

Keyboard shortcuts

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