middleware

package
v0.1.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentTypeJSON

func ContentTypeJSON(next http.Handler) http.Handler

ContentTypeJSON sets the content type for requests to application/json

Types

type AccessType

type AccessType string

AccessType represents the various access types for a project

const (
	ReadAccess  AccessType = "read"
	WriteAccess AccessType = "write"
)

The various access types

type Auth

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

Auth implements the authorization functions

func NewAuth

func NewAuth(
	store sessions.Store,
	cookieName string,
	repo *repository.Repository,
) *Auth

NewAuth returns a new Auth instance

func (*Auth) BasicAuthenticate

func (auth *Auth) BasicAuthenticate(next http.Handler) http.Handler

BasicAuthenticate just checks that a user is logged in

func (*Auth) DoesUserHaveClusterAccess

func (auth *Auth) DoesUserHaveClusterAccess(
	next http.Handler,
	projLoc IDLocation,
	clusterLoc IDLocation,
) http.Handler

DoesUserHaveClusterAccess looks for a project_id parameter and a cluster_id parameter, and verifies that the cluster belongs to the project

func (*Auth) DoesUserHaveGitRepoAccess

func (auth *Auth) DoesUserHaveGitRepoAccess(
	next http.Handler,
	projLoc IDLocation,
	gitRepoLoc IDLocation,
) http.Handler

DoesUserHaveGitRepoAccess looks for a project_id parameter and a git_repo_id parameter, and verifies that the git repo belongs to the project

func (*Auth) DoesUserHaveInfraAccess

func (auth *Auth) DoesUserHaveInfraAccess(
	next http.Handler,
	projLoc IDLocation,
	infraLoc IDLocation,
) http.Handler

DoesUserHaveInfraAccess looks for a project_id parameter and an infra_id parameter, and verifies that the infra belongs to the project

func (*Auth) DoesUserHaveProjectAccess

func (auth *Auth) DoesUserHaveProjectAccess(
	next http.Handler,
	projLoc IDLocation,
	accessType AccessType,
) http.Handler

DoesUserHaveProjectAccess looks for a project_id parameter and checks that the user has access via the specified accessType

func (*Auth) DoesUserHaveRegistryAccess

func (auth *Auth) DoesUserHaveRegistryAccess(
	next http.Handler,
	projLoc IDLocation,
	registryLoc IDLocation,
) http.Handler

DoesUserHaveRegistryAccess looks for a project_id parameter and a registry_id parameter, and verifies that the registry belongs to the project

func (*Auth) DoesUserIDMatch

func (auth *Auth) DoesUserIDMatch(next http.Handler, loc IDLocation) http.Handler

DoesUserIDMatch checks the id URL parameter and verifies that it matches the one stored in the session

type IDLocation

type IDLocation uint

IDLocation represents the location of the ID to use for authentication

const (
	// URLParam location looks for a parameter in the URL endpoint
	URLParam IDLocation = iota
	// BodyParam location looks for a parameter in the body
	BodyParam
	// QueryParam location looks for a parameter in the query string
	QueryParam
)

Jump to

Keyboard shortcuts

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