context

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 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 {
	Email       string             `json:"email"`
	Teams       []string           `json:"teams"`
	Permissions userv1.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) GetPluginPermissions

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) HasApplicationAccess

func (u *User) HasApplicationAccess(satellite, cluster, namespace string, teams []string) bool

HasApplicationAccess checks if the user is allowed to view an application.

func (*User) HasPluginAccess

func (u *User) HasPluginAccess(satellite, pluginType, pluginName string) bool

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

func (*User) HasResourceAccess

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

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

func (*User) HasTeamAccess

func (u *User) HasTeamAccess(teamGroup string) bool

HasTeamAccess checks if the user is allowed to view a team. Teams are identified by the group property.

func (*User) ToString

func (u *User) ToString() string

ToString returns the marshaled user object.

Jump to

Keyboard shortcuts

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