Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMissingToken = errors.New("an authorization token must be provided") )
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 ¶
StratumnAccountMiddleware implements the Middleware interface. It provides authentication using Stratumn Account API.
func (*StratumnAccountMiddleware) WithAuth ¶
func (s *StratumnAccountMiddleware) WithAuth(next http.HandlerFunc) http.HandlerFunc
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.
Click to show internal directories.
Click to hide internal directories.