authn

package
v0.0.0-...-2523971 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Provider = providerKey{}

Provider is used to add an authn.Client as an api.Router provider

Functions

func Directive

func Directive() service.Directive

Directive is a shortcut for calling New() and Directive()

Types

type AuthN

type AuthN struct {
	// Host holds the authn-server endpoint (domain name)
	// It is used as the JWT token issuer as wel
	Host string

	// PrivateBaseURL can be used to configure a different domain name
	// when interacting with a private API endpoint of the authn-server
	PrivateBaseURL string

	// Audience configures the audience that is allowed to use the service
	// If set, the first audience configured is the "main" audience and used
	// by default
	Audience []string

	// Username is the HTTP Basic-Authentication username required for private
	// authn-server endpoints
	Username string

	// Password is the HTTP Basic-Authenticaiton password required for private
	// authn-server endpoints
	Password string
}

AuthN holds the configuration for the authn-server that is used for any authentication requests

func New

func New() *AuthN

New returns a new AuthN configuration struct

func (*AuthN) Client

func (an *AuthN) Client() (*Client, error)

Client returns an authn.Client that based on the configuration values in an

func (*AuthN) Directive

func (an *AuthN) Directive() service.Directive

Directive returns a configuration directive that configures the AuthN client. Once configured the client is added to the api.Router and also configures the token subject extractor function of the router

type Client

type Client struct {
	*authn.Client
	// contains filtered or unexported fields
}

Client extends authn.Client and overwrites SubjectFrom

func FromRouter

func FromRouter(r api.Router) *Client

FromRouter returns the authn.Client that is associated with the service router r

func (*Client) Audience

func (c *Client) Audience() []string

Audience returns the list of allowed JWT audiences

func (*Client) Host

func (c *Client) Host() string

Host returns the authn-server address

func (*Client) SubjectFrom

func (cli *Client) SubjectFrom(idToken string) (string, error)

SubjectFrom extends the SubjectFrom method of the underlying authn.Client

Jump to

Keyboard shortcuts

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