tokenauth

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	Name   string    `json:"name,omitempty"`        // Name of the token
	Value  string    `json:"token,omitempty"`       // Token value
	Expire time.Time `json:"expire_time,omitempty"` // Time of expiration for the token
	Time   time.Time `json:"access_time"`           // Time of last access
	Scope  []string  `json:"scopes,omitempty"`      // Authentication scopes
}

func NewToken

func NewToken(length int, duration time.Duration, scope ...string) *Token

func (*Token) IsScope

func (t *Token) IsScope(scopes ...string) bool

Return true if the token has the specified scope, and is valid

func (*Token) IsValid

func (t *Token) IsValid() bool

Return true if the token is valid (not expired)

func (*Token) MarshalJSON

func (t *Token) MarshalJSON() ([]byte, error)

func (*Token) String

func (t *Token) String() string

type TokenCreate

type TokenCreate struct {
	Duration time.Duration `json:"duration,omitempty"` // Duration of the token, or zero for no expiration
	Scope    []string      `json:"scopes,omitempty"`   // Authentication scopes
}

Jump to

Keyboard shortcuts

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