Documentation ¶
Index ¶
- Constants
- type AccessKeyContextKey
- type AccessService
- type AuthMiddleware
- func (m *AuthMiddleware) Guard(requiredPermission permissions.Operation) func(http.HandlerFunc) http.HandlerFunc
- func (m *AuthMiddleware) GuardDashboard() func(http.HandlerFunc) http.HandlerFunc
- func (m *AuthMiddleware) LoginHandler(w http.ResponseWriter, r *http.Request)
- func (m AuthMiddleware) LogoutHandler(w http.ResponseWriter, r *http.Request)
- type ConfigurationService
- type PermissionsBuilder
- type Templates
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 PermissionsBuilder ¶
type PermissionsBuilder interface {
NewAccessKeyPermissions() *permissions.AccessKeyPermissions
}
type Templates ¶
type Templates interface { Login(w http.ResponseWriter, errMsg string) LoginError(w http.ResponseWriter, errMsg string) }
Click to show internal directories.
Click to hide internal directories.