token

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Scopes = map[ScopeCode]Scope{
	ScopeAPIToken: {
		Code:  ScopeAPIToken,
		Title: "Allows requests to go-api API",
		Value: "apitoken",
	},
	ScopeMockAPI: {
		Code:  ScopeMockAPI,
		Title: "Allows requests to mock API",
		Value: "mockapi",
	},
}

Functions

func GenerateRawToken

func GenerateRawToken() string

func HashToken

func HashToken(secret, token string) string

Types

type LiteToken

type LiteToken struct {
	Id          string      `json:"id"`
	Timestamp   int64       `json:"timestamp"`
	Expire      int64       `json:"expire"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Scopes      []ScopeCode `json:"scopes"`
	Owner       string      `json:"owner"`
}

func ToLiteToken

func ToLiteToken(token Token) LiteToken

type Repository

type Repository interface {
	FindAll(owner string) []LiteToken
	Find(id string) (*Token, bool)
	FindGlobal(token string) (*Token, bool)
	FindByName(owner, name string) (*Token, bool)
	FindByToken(owner, token string) (*Token, bool)
	Insert(owner string, token *Token) *Token
	Delete(token *Token) *Token
}

type Scope

type Scope struct {
	Code  ScopeCode `json:"code"`
	Title string    `json:"title"`
	Value string    `json:"value"`
}

func ListScopes

func ListScopes() []Scope

type ScopeCode

type ScopeCode string
const (
	ScopeAPIToken ScopeCode = "apitoken"
	ScopeMockAPI  ScopeCode = "mockapi"
)

type ScopeData

type ScopeData Scope

type Token

type Token struct {
	Id          string      `json:"id"`
	Timestamp   int64       `json:"timestamp"`
	Expire      int64       `json:"expire"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Token       string      `json:"token"`
	Scopes      []ScopeCode `json:"scopes"`
	Owner       string      `json:"owner"`
}

func ToToken

func ToToken(hash string, token LiteToken) Token

func (Token) IsExipred

func (r Token) IsExipred() bool

func (Token) PersistenceId

func (r Token) PersistenceId() string

Jump to

Keyboard shortcuts

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