token

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithPermission

func ContextWithPermission(ctx context.Context, p Permission) context.Context

Types

type Config

type Config struct {
	Static *ConfigStatic `yaml:"static,omitempty"`
}

type ConfigMappings

type ConfigMappings struct {
	Permission Permission `yaml:"permission,omitempty"`
	Caches     []string   `yaml:"caches,omitempty"`
}

type ConfigStatic

type ConfigStatic struct {
	Tokens   []Token          `yaml:"tokens,omitempty"`
	Mappings []ConfigMappings `yaml:"mappings,omitempty"`
}

type Handler

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

func New

func New(cfg []Config) *Handler

func (*Handler) Middleware

func (h *Handler) Middleware(next http.Handler) http.Handler

type Permission

type Permission int8
const (
	PermissionAnonymous Permission = iota
	PermissionRead
	PermissionWrite
	PermissionAdmin
)

func PermissionFromContext

func PermissionFromContext(ctx context.Context) Permission

func (Permission) MarshalYAML

func (p Permission) MarshalYAML() (interface{}, error)

func (Permission) String

func (p Permission) String() string

func (*Permission) UnmarshalYAML

func (p *Permission) UnmarshalYAML(value *yaml.Node) error

type Token

type Token string

func (Token) MarshalYAML

func (t Token) MarshalYAML() (interface{}, error)

Jump to

Keyboard shortcuts

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