go-micro: github.com/micro/go-micro/auth Index | Files | Directories

package auth

import "github.com/micro/go-micro/auth"

Package auth provides authentication and authorization capability

Index

Package Files

auth.go default.go options.go

func Metadata Uses

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

Metadata for the generated account

func Roles Uses

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

Roles for the generated account

type Account Uses

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 Uses

type Auth interface {
    // 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)
    // String returns the implementation
    String() string
}

Auth providers authentication and authorization

var (
    DefaultAuth Auth = new(noop)
)

type GenerateOption Uses

type GenerateOption func(o *GenerateOptions)

type GenerateOptions Uses

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

func NewGenerateOptions Uses

func NewGenerateOptions(opts ...GenerateOption) GenerateOptions

NewGenerateOptions from a slice of options

type Option Uses

type Option func(o *Options)

func Excludes Uses

func Excludes(excludes ...string) Option

Excludes endpoints from auth

func PrivateKey Uses

func PrivateKey(key string) Option

PrivateKey is the JWT private key

func PublicKey Uses

func PublicKey(key string) Option

PublicKey is the JWT public key

type Options Uses

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

type Resource Uses

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 Uses

type Role struct {
    Name     string
    Resource *Resource
}

Role an account has

Directories

PathSynopsis
jwt
service
service/proto

Package auth imports 2 packages (graph). Updated 2020-02-19. Refresh now. Tools for package owners.