middleware

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authorization

func Authorization(auth Authorizer) echo.MiddlewareFunc

Authorization returns a new authorization middleware func by using the input authorizer.

Types

type Authorizer

type Authorizer interface {
	Authorize(r *http.Request) error
}

Authorizer represents an authorization mechanism applied to an HTTP request.

type TagAuthorizer

type TagAuthorizer struct {
	// contains filtered or unexported fields
}

TagAuthorizer performs authorization based on the TAG scheme for the authorization header.

func NewTagAuthorizer

func NewTagAuthorizer(db storage.Storage, log echo.Logger) *TagAuthorizer

NewTagAuthorizer builds a new tag based authorizer. This type of authorizer matches the tag passed in through the authorization header against the tag associated with the resource that the request tries to modify.

func (*TagAuthorizer) Authorize

func (a *TagAuthorizer) Authorize(r *http.Request) error

Authorize authorizes HTTP request by verifying resource ownership. It does so by retrieving the tag included in the http request's authorization header and comparing it with the tags associated with the resource that the request is trying to modify. If request tag is among the ones associated with the resource, then action is granted. Otherwise it is denied.

Jump to

Keyboard shortcuts

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