auth

package
v0.0.0-...-ea6506d Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExpired = errors.New("token expired")

ErrExpired is returned when the user tries to autneticate with an expired token.

Functions

func Context

func Context(ctx context.Context, opts ...ContextOpt) context.Context

Context decorates a context with an auth.Info object containing information about the current user and their privileges.

Types

type ContextOpt

type ContextOpt func(*Info)

ContextOpt values are passed to auth.Context to construct an auth.Info object

func Admin

func Admin(isAdmin bool) ContextOpt

Admin is passed as an argument to Context to set the auth.Info's IsAdmin flag

func ID

func ID(id string) ContextOpt

ID is passed as an argument to Context to set the auth.Info's ID

type FirebaseProvider

type FirebaseProvider struct {
	AuthClient *auth.Client
	AdminUIDs  []string
}

FirebaseProvider is an auth provider backed by Firebase Authentication

func (*FirebaseProvider) FromRequest

func (f *FirebaseProvider) FromRequest(r *http.Request) (Info, error)

FromRequest parses an Authorization header or Cookie as a Firebase JWT token.

type Info

type Info struct {
	ID      string
	IsAdmin bool
}

Info stores information about the current user

func User

func User(ctx context.Context) Info

User returns an auth.Info object stored in a context

func (Info) WithContext

func (i Info) WithContext(ctx context.Context) context.Context

WithContext decorates a context with this auth.Info object. Use auth.User to retrieve the auth.Info from the context.

type Provider

type Provider interface {
	FromRequest(r *http.Request) (Info, error)
}

Provider parses requests to extract authorization info.

Jump to

Keyboard shortcuts

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