mockauth

package
v0.0.1-79 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserExists = errors.New("user already exists")
)

This is a list of errors we support

Functions

This section is empty.

Types

type ClusterRole

type ClusterRole struct {
	Role        string
	Name        string
	Description string
}

ClusterRole represents the roles of a cluster.

type Engine

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

Engine represents the high level user management engine.

func NewEngine

func NewEngine() *Engine

NewEngine creates a new user management engine.

func (*Engine) DropUser

func (e *Engine) DropUser(username string) error

DropUser deletes a user.

func (*Engine) GetAllClusterRoles

func (e *Engine) GetAllClusterRoles() []*ClusterRole

GetAllClusterRoles returns a list of all known cluster roles.

func (*Engine) GetAllUsers

func (e *Engine) GetAllUsers() []*User

GetAllUsers returns a list of all registered users.

func (*Engine) GetUser

func (e *Engine) GetUser(username string) *User

GetUser retrieves a user by their username.

func (*Engine) UpsertUser

func (e *Engine) UpsertUser(opts UpsertUserOptions) error

UpsertUser creates or updates a user.

type Group

type Group struct {
	Name  string
	Roles []*UserRole
}

Group represents a group that a user may be part of.

type Permission

type Permission uint8

Permission represents a permission a user may need for an operation.

const (
	PermissionDataRead Permission = iota + 1
	PermissionDataWrite
	PermissionUserRead
	PermissionUserManage
	PermissionViewsRead
	PermissionViewsManage
	PermissionDCPRead
	PermissionSearchRead
	PermissionSearchManage
	PermissionQueryRead
	PermissionQueryWrite
	PermissionQueryDelete
	PermissionQueryManage
	PermissionAnalyticsRead
	PermissionsAnalyticsManage
	PermissionSyncGateway
	PermissionStatsRead
	PermissionReplicationTarget
	PermissionReplicationManage
	PermissionClusterRead
	PermissionClusterManage
	PermissionBucketManage
	PermissionSettings
	PermissionSelect
)

Various permissions which can be required.

type UpsertUserOptions

type UpsertUserOptions struct {
	Username    string
	DisplayName string
	// Roles are the roles assigned to the user that are of type "user".
	Roles    []string
	Groups   []string
	Password string
}

UpsertUserOptions allows you to specify initial options for a new user.

type User

type User struct {
	DisplayName string
	Username    string
	Password    string
	Groups      []*Group
	Roles       []*UserRole
}

User represents a single user in the system.

func (*User) HasPermission

func (u *User) HasPermission(permission Permission, bucket, scope, collection string) bool

HasPermission checks whether this user has a specific permission, including all roles and groups.

type UserRole

type UserRole struct {
	Name           string
	BucketName     string
	ScopeName      string
	CollectionName string
}

UserRole represents the roles of a user.

Jump to

Keyboard shortcuts

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