context

package
Version: v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const UserKey ctxKeyUser = 0

UserKey is the key that holds the user in a request context.

Variables

This section is empty.

Functions

This section is empty.

Types

type User

type User struct {
	ID          string           `json:"id"`
	HasProfile  bool             `json:"hasProfile"`
	Profile     user.UserSpec    `json:"profile,omitempty"`
	Permissions team.Permissions `json:"permissions"`
}

User is the structure of the user object saved in the request context. It contains the users id and permissions if authentication is enabled.

func GetUser

func GetUser(ctx context.Context) (*User, error)

GetUser returns a user from the given context if one is present. Returns the empty string if a user can not be found.

func (*User) HasClusterAccess

func (u *User) HasClusterAccess(cluster string) bool

HasClusterAccess checks if the user has access to the given cluster.

func (*User) HasNamespaceAccess

func (u *User) HasNamespaceAccess(cluster, namespace string) bool

HasNamespaceAccess checks if the user has access to the given namespace in the given cluster.

func (*User) HasPluginAccess

func (u *User) HasPluginAccess(plugin string) bool

HasPluginAccess checks if the user has access to the given plugin.

func (*User) HasResourceAccess

func (u *User) HasResourceAccess(cluster, namespace, name string) bool

HasResourceAccess checks if the user has access to the given resource in the given cluster and namespace.

Source Files

Jump to

Keyboard shortcuts

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