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

package auth

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

Package auth is an interface for authentication and authorization.

Index

Package Files

auth.go context.go options.go os.go util.go wrapper.go

Variables

var (
    ErrInvalidToken = errors.New("invalid token")
)

func ClientWrapper Uses

func ClientWrapper(a Auth) client.Wrapper

func ContextWithToken Uses

func ContextWithToken(ctx context.Context, t *Token) context.Context

func HandlerWrapper Uses

func HandlerWrapper(a Auth) server.HandlerWrapper

func HeaderWithToken Uses

func HeaderWithToken(hd map[string]string, t *Token) map[string]string

func NewContext Uses

func NewContext(ctx context.Context, c Auth) context.Context

type Auth Uses

type Auth interface {
    // Check if authorised
    Authorized(ctx context.Context, req Request) (*Token, error)
    // Retrieve token from context
    Introspect(ctx context.Context) (*Token, error)
    // Revoke a token
    Revoke(t *Token) error
    // Retrieve client token
    Token() (*Token, error)
    String() string
}

Auth handles client side validation of authentication The client does not actually handle authentication itself. This could be an oauth2 provider, openid, basic auth, etc.

func FromContext Uses

func FromContext(ctx context.Context) (Auth, bool)

func NewAuth Uses

func NewAuth(opts ...Option) Auth

type Option Uses

type Option func(*Options)

func Client Uses

func Client(c client.Client) Option

func Id Uses

func Id(id string) Option

func Secret Uses

func Secret(s string) Option

type Options Uses

type Options struct {
    Id     string
    Secret string
    Client client.Client
    // Used for alternative options
    Context context.Context
}

type Request Uses

type Request interface {
    Service() string
    Method() string
}

Client or server request

type Token Uses

type Token struct {
    AccessToken  string
    RefreshToken string
    TokenType    string
    ExpiresAt    time.Time
    Scopes       []string
    Metadata     map[string]string
}

Basically identical to oauth token

func TokenFromContext Uses

func TokenFromContext(ctx context.Context) (*Token, bool)

func TokenFromHeader Uses

func TokenFromHeader(hd map[string]string) (*Token, bool)

Directories

PathSynopsis
protoPackage go_micro_os_auth is a generated protocol buffer package.

Package auth imports 9 packages (graph) and is imported by 4 packages. Updated 2018-05-23. Refresh now. Tools for package owners.