auth

package
v0.0.0-...-a5ffb17 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Owners *Owners
}

Auth is a SecurityLayer used to enforce security checks on client requests. Use NewAuth to create a new instance.

func NewAuth

func NewAuth(owners *Owners) *Auth

NewAuth creates a new instance of the auth layer.

func (*Auth) Authenticate

func (a *Auth) Authenticate(handler http.Handler) http.Handler

Authenticate performs an authentication check on an HTTP Handler.

func (*Auth) Authorize

func (a *Auth) Authorize(handler http.Handler) http.Handler

Authorize performs a resource-ownership check on an HTTP handler.

type Owners

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

Owners is the OwnershipRecorder used by the auth layer. Use NewOwners to create a new instance.

func NewOwners

func NewOwners() *Owners

NewOwners creates a new instance of the owner log.

func (*Owners) IsOwner

func (ot *Owners) IsOwner(username, id string) bool

IsOwner returns true only if the given user is the registered owner of the resource represented by the given id.

func (*Owners) SetOwner

func (ot *Owners) SetOwner(username, id string)

SetOwner registers the given user as the owner of the resource with the given id.

type OwnershipRecorder

type OwnershipRecorder interface {
	SetOwner(username, id string)
	IsOwner(username, id string) bool
}

OwnershipRecorder assists in request authorization by tracking resource ownership.

type SecurityLayer

type SecurityLayer interface {
	Authenticate(handler http.Handler) http.Handler
	Authorize(handler http.Handler) http.Handler
}

A SecurityLayer can perform security checks on HTTP handlers.

Jump to

Keyboard shortcuts

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