auth

package
v0.0.0-...-6d02989 Latest Latest
Warning

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

Go to latest
Published: May 24, 2019 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingToken = errors.New("an authorization token must be provided")

	ErrUnauthorizedAccount = errors.New("user is not part of the authorized entities")
)

Those are the errors returned by the middleware.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	AccountID       string   `json:"accountId"`
	OtherAccountIDs []string `json:"otherAccountIds"`
}

AccountInfo contains the data returned by StratumnAccount `GET /info` call.

type Middleware

type Middleware interface {
	WithAuth(next http.HandlerFunc) http.HandlerFunc
}

Middleware is the interface exposing a middleware function providing authentication.

func NewStratumnAccountMiddleware

func NewStratumnAccountMiddleware(accountURL string, authorizedAccounts []string) (Middleware, error)

NewStratumnAccountMiddleware returns a new instance of StratumnAccountMiddleware.

type StratumnAccountMiddleware

type StratumnAccountMiddleware struct {
	AccountURL         string
	AuthorizedAccounts []string
}

StratumnAccountMiddleware implements the Middleware interface. It provides authentication using Stratumn Account API.

func (*StratumnAccountMiddleware) WithAuth

WithAuth is a middleware function. The incoming request must have an 'authorization' header, which is relayed to the 'GET /info' route of the Account API. The request is rejected if a 401 is returned and goes through otherwise.

Jump to

Keyboard shortcuts

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