auth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthService

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

func New

func New(kvs kvs.KeyValueStore) *AuthService

func (*AuthService) CreateToken

func (a *AuthService) CreateToken(ctx context.Context, userID uint, scopes []Scope) (*Token, error)

func (*AuthService) Get

func (a *AuthService) Get(ctx context.Context, token string) (*Token, error)

func (*AuthService) RevokeToken

func (a *AuthService) RevokeToken(ctx context.Context, token string) error

type Scope

type Scope string
const (
	NoScope    Scope = ""
	ScopeAdmin Scope = "admin"
)

type Token

type Token struct {
	Token     string    `json:"token"`
	UserID    uint      `json:"userID"`
	Scopes    []Scope   `json:"scopes"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

func (*Token) HasScope

func (t *Token) HasScope(scope Scope) bool

Jump to

Keyboard shortcuts

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