Documentation ¶
Index ¶
Constants ¶
const ( SigningAlgorithm = "HS256" NamespaceClaim = "namespace" )
JWT related constants
Variables ¶
var ( // ErrUnrecognizedToken is returned when a token has been provided to an authenticator which does not recognize it ErrUnrecognizedToken = errors.New("unrecognized token") 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(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 ¶
NamespaceFrom returns the namespace identified by the given string