auth

package
v0.0.0-...-e163d20 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdminUsernameEnv = "CG_ADMIN_USERNAME"
	AdminPasswordEnv = "CG_ADMIN_PASSWORD"
	AccessKeyHeader  = "X-Access-Key"
	AccessKeyCookies = "AccessKey"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessKeyContextKey

type AccessKeyContextKey struct{}

type AccessService

type AccessService interface {
	GetAccessKeyPermissions(ctx context.Context, key string) (*permissions.AccessKeyPermissions, bool, error)
	GenerateAccessKey(ctx context.Context, accessKeyPerms dto.AccessKeyPermissionsDto) (dto.AccessKeyPermissionsDto, error)
	DeleteAccessKeys(ctx context.Context, keys []string) error
}

type AuthMiddleware

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

AuthMiddleware holds the service needed to validate permissions

func NewAuthMiddleware

func NewAuthMiddleware(access AccessService, configuration ConfigurationService, perms PermissionsBuilder, templates Templates) *AuthMiddleware

NewAuthMiddleware creates a new instance of AuthMiddleware

func (*AuthMiddleware) Guard

func (m *AuthMiddleware) Guard(requiredPermission permissions.Operation) func(http.HandlerFunc) http.HandlerFunc

Guard creates a middleware that checks for the required permissions

func (*AuthMiddleware) GuardDashboard

func (m *AuthMiddleware) GuardDashboard() func(http.HandlerFunc) http.HandlerFunc

GuardDashboard creates a middleware that checks for the required permissions for dashboard

func (*AuthMiddleware) LoginHandler

func (m *AuthMiddleware) LoginHandler(w http.ResponseWriter, r *http.Request)

func (AuthMiddleware) LogoutHandler

func (m AuthMiddleware) LogoutHandler(w http.ResponseWriter, r *http.Request)

type ConfigurationService

type ConfigurationService interface {
	GetEnvOriginal(ctx context.Context, env string) (string, bool, error)
	IsEnvOriginal(ctx context.Context, env string) bool
}

type PermissionsBuilder

type PermissionsBuilder interface {
	NewAccessKeyPermissions() *permissions.AccessKeyPermissions
}

type Templates

type Templates interface {
	Login(w http.ResponseWriter, errMsg string)
	LoginError(w http.ResponseWriter, errMsg string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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