auth

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: Apache-2.0 Imports: 2 Imported by: 49

Documentation

Overview

Package auth provides authentication and authorization capability

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Metadata added in v2.1.0

func Metadata(md map[string]string) func(o *GenerateOptions)

Metadata for the generated account

func Roles added in v2.1.0

func Roles(rs []*Role) func(o *GenerateOptions)

Roles for the generated account

Types

type Account added in v2.1.0

type Account struct {
	// ID of the account (UUID or email)
	Id string `json: "id"`
	// Token used to authenticate
	Token string `json: "token"`
	// Time of Account creation
	Created time.Time `json:"created"`
	// Time of Account expiry
	Expiry time.Time `json:"expiry"`
	// Roles associated with the Account
	Roles []*Role `json:"roles"`
	// Any other associated metadata
	Metadata map[string]string `json:"metadata"`
}

Account provided by an auth provider

type Auth

type Auth interface {
	// String to identify the package
	String() string
	// Init the auth package
	Init(opts ...Option) error
	// Options returns the options set
	Options() Options
	// Generate a new auth Account
	Generate(id string, opts ...GenerateOption) (*Account, error)
	// Revoke an authorization Account
	Revoke(token string) error
	// Validate an account token
	Validate(token string) (*Account, error)
}

Auth providers authentication and authorization

var (
	DefaultAuth Auth = new(noop)
)

type GenerateOption added in v2.1.0

type GenerateOption func(o *GenerateOptions)

type GenerateOptions added in v2.1.0

type GenerateOptions struct {
	Metadata map[string]string
	Roles    []*Role
}

func NewGenerateOptions added in v2.1.0

func NewGenerateOptions(opts ...GenerateOption) GenerateOptions

NewGenerateOptions from a slice of options

type Option added in v2.1.0

type Option func(o *Options)

func Excludes added in v2.1.0

func Excludes(excludes ...string) Option

Excludes endpoints from auth

func PrivateKey added in v2.1.0

func PrivateKey(key string) Option

PrivateKey is the JWT private key

func PublicKey added in v2.1.0

func PublicKey(key string) Option

PublicKey is the JWT public key

type Options added in v2.1.0

type Options struct {
	PublicKey  []byte
	PrivateKey []byte
	Excludes   []string
}

type Resource added in v2.1.0

type Resource struct {
	// Name of the resource
	Name string
	// Type of resource, e.g.
	Type string
}

Resource is an entity such as a user or

type Role added in v2.1.0

type Role struct {
	Name     string
	Resource *Resource
}

Role an account has

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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