middleware

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: MIT Imports: 13 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,
	tokenConf *token.TokenGeneratorConf,
	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) BasicAuthenticateWithRedirect

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

BasicAuthenticateWithRedirect checks that a user is logged in, and if they're not, the user is redirected to the login page with the redirect path stored in the session

func (*Auth) DoesUserHaveAWSIntegrationAccess

func (auth *Auth) DoesUserHaveAWSIntegrationAccess(
	next http.Handler,
	projLoc IDLocation,
	awsLoc IDLocation,
	optional bool,
) http.Handler

DoesUserHaveAWSIntegrationAccess looks for a project_id parameter and an aws_integration_id parameter, and verifies that the infra belongs to the project

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) DoesUserHaveDOIntegrationAccess

func (auth *Auth) DoesUserHaveDOIntegrationAccess(
	next http.Handler,
	projLoc IDLocation,
	doLoc IDLocation,
	optional bool,
) http.Handler

DoesUserHaveDOIntegrationAccess looks for a project_id parameter and an do_integration_id parameter, and verifies that the infra belongs to the project

func (*Auth) DoesUserHaveGCPIntegrationAccess

func (auth *Auth) DoesUserHaveGCPIntegrationAccess(
	next http.Handler,
	projLoc IDLocation,
	gcpLoc IDLocation,
	optional bool,
) http.Handler

DoesUserHaveGCPIntegrationAccess looks for a project_id parameter and an gcp_integration_id parameter, and verifies that the infra 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) DoesUserHaveInviteAccess

func (auth *Auth) DoesUserHaveInviteAccess(
	next http.Handler,
	projLoc IDLocation,
	inviteLoc IDLocation,
) http.Handler

DoesUserHaveInviteAccess looks for a project_id parameter and a invite_id parameter, and verifies that the invite 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
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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