context

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 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 {
	Cluster     string                 `json:"cluster"`
	Namespace   string                 `json:"namespace"`
	Name        string                 `json:"name"`
	ID          string                 `json:"id"`
	Profile     userv1.Profile         `json:"profile"`
	Teams       []userv1.TeamReference `json:"teams"`
	Permissions userv1.Permissions     `json:"permissions"`
	Rows        []dashboardv1.Row      `json:"rows"`
}

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) GetPluginPermissions added in v0.8.0

func (u *User) GetPluginPermissions(name string) [][]byte

GetPluginPermissions returns the custom plugin permissions for a user. For that the name of the plugin must be provided.

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, verb string) bool

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

Jump to

Keyboard shortcuts

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