user

package
v0.0.0-...-5b6efc0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const CustomRolePattern string = "--$"

Variables

View Source
var ListGroupsCanCreateWorkspaces = [3]string{"admin", "developer-admin", "sandbox-developer"}
View Source
var ListGroupsCanSeeCustomRoles = [3]string{"admin", "developer-admin", "sandbox-developer"}

Functions

func CanCreateWorkspaces

func CanCreateWorkspaces(user User) bool

func CanSeeCustomRoles

func CanSeeCustomRoles(u User) bool

func HasOwnership

func HasOwnership(u User, roles []Role) bool

func UserContext

func UserContext(user User, ctx context.Context) context.Context

adds the User to the given context

func UserHasRole

func UserHasRole(u User, entry Role) bool

Types

type ContextKey

type ContextKey int
const (
	UserKey ContextKey = iota
)

type MockUser

type MockUser struct {
	Uid   string
	Name  string
	Email string
	Roles []Role
}

a mock user for tests

func (MockUser) GetEmail

func (u MockUser) GetEmail() string

func (MockUser) GetName

func (u MockUser) GetName() string

func (MockUser) GetRoles

func (u MockUser) GetRoles() []Role

func (MockUser) GetUid

func (u MockUser) GetUid() string

type Role

type Role string

type User

type User interface {
	GetUid() string
	GetName() string
	GetEmail() string
	GetRoles() []Role
}

tightly modelled on JWT: http://jwt.io

func GetUser

func GetUser(ctx context.Context) User

Jump to

Keyboard shortcuts

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