Help us shape the future of Go! Take the 2026 Go Developer Survey

authserver

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken = errors.New("token is invalid")
	ErrExpiredToken = errors.New("token has expired")
)

Functions

func CreateToken

func CreateToken(upn string, access_id int, client_id string) (string, time.Time, error)

func Init

func Init(cfg *utils.Config)

Types

type JWTMaker

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

func (*JWTMaker) CreateToken

func (maker *JWTMaker) CreateToken(upn string, access_id int, client_id string, duration time.Duration) (string, time.Time, error)

func (*JWTMaker) VerifyToken

func (maker *JWTMaker) VerifyToken(token string) (*Payload, error)

type Maker

type Maker interface {
	CreateToken(upn string, access_id int, client_id string, duration time.Duration) (string, time.Time, error)
	VerifyToken(token string) (*Payload, error)
}

func NewJWTMaker

func NewJWTMaker(secretKey string) (Maker, error)

type Payload

type Payload struct {
	ID        uuid.UUID `json:"id"`
	UPN       string    `json:"upn"`
	AccessID  int       `json:"access_id"`
	ClientID  string    `json:"client_id"`
	IssuedAt  time.Time `json:"issued_at"`
	ExpiredAt time.Time `json:"expired_at"`
}

func NewPayload

func NewPayload(upn string, access_id int, client_id string, duration time.Duration) (*Payload, error)

func VerifyToken

func VerifyToken(token string) (*Payload, error)

func (*Payload) Valid

func (payload *Payload) Valid() error

Jump to

Keyboard shortcuts

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