auth

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: Apache-2.0 Imports: 4 Imported by: 106

Documentation

Index

Constants

View Source
const (
	SigningAlgorithm = "HS256"
	NamespaceClaim   = "namespace"
)

JWT related constants

View Source
const (

	// ContextHeadersKey is the key in the context for the headers passed to the Authenticators from the auth middleware
	ContextHeadersKey = "headers"
)

Variables

View Source
var (
	// ErrUnrecognizedToken is returned when a token has been provided to an authenticator which does not recognize it
	ErrUnrecognizedToken = errors.New("unrecognized token")

	// ErrUnauthorized is returned when the token is not valid
	ErrUnauthorized = errors.New("unauthorized")

	// ErrEmptyToken is returned when an empty token has been provided to an authenticator which does not support it
	ErrEmptyToken = errors.New("empty token")

	// ErrCommunicationError is returned when an authenticator is unable to communicate with the token issuer,
	// and hence unavailable to authorize (or unauthorize) a token.
	ErrCommunicationError = errors.New("communication error")
)

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {

	// Authenticate resolves an arbitrary string token into a namespace.
	Authenticate(ctx context.Context, token string) (*Namespace, error)
}

Authenticator is an interface for token authentication

func DefaultAuthenticator

func DefaultAuthenticator() Authenticator

DefaultAuthenticator returns the default authenticator provided by this package, which resolves "" (empty string) as well as "default" token to the default namespace.

func NewChainAuthenticator

func NewChainAuthenticator(auths []Authenticator) (Authenticator, error)

NewChainAuthenticator creates and initializes a new chain authenticator, wrapping the given authenticators.

func NewJWTAuthenticator

func NewJWTAuthenticator(key []byte) (Authenticator, error)

NewJWTAuthenticator creates a new Json-Web-Token authenticator based on the provided configuration options. Returns a valid Authenticator interface on success or an error on failure

func NewTrustedAuthenticator

func NewTrustedAuthenticator() Authenticator

NewTrustedAuthenticator creates a trusted authenticator instance

type Namespace

type Namespace string

Namespace represents the service registration and discovery scope

func NamespaceFrom

func NamespaceFrom(s string) Namespace

NamespaceFrom returns the namespace identified by the given string

func (Namespace) String

func (ns Namespace) String() string

String returns the string representation of the given Namespace

Jump to

Keyboard shortcuts

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