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 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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