user

package
v0.0.0-...-fb7f86c Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QuotaTargetSrv string = "user"
	QuotaTarget    string = "user"
)

Variables

View Source
var (
	ErrCaseInsensitive   = errors.New("case insensitive conflict")
	ErrUserNotFound      = errors.New("user not found")
	ErrUserAlreadyExists = errors.New("user already exists")
	ErrLastGrafanaAdmin  = errors.New("cannot remove last grafana admin")
	ErrProtectedUser     = errors.New("cannot adopt protected user")
	ErrNoUniqueID        = errors.New("identifying id not found")
	ErrLastSeenUpToDate  = errors.New("last seen is already up to date")
	ErrUpdateInvalidID   = errors.New("unable to update invalid id")
)

Typed errors

Functions

This section is empty.

Types

type AdminCreateUserResponse

type AdminCreateUserResponse struct {
	ID      int64  `json:"id"`
	Message string `json:"message"`
}

type AnalyticsSettings

type AnalyticsSettings struct {
	Identifier         string
	IntercomIdentifier string
}

type AuthModuleConversion

type AuthModuleConversion []string

implement Conversion interface to define custom field mapping (xorm feature)

func (*AuthModuleConversion) FromDB

func (auth *AuthModuleConversion) FromDB(data []byte) error

func (*AuthModuleConversion) ToDB

func (auth *AuthModuleConversion) ToDB() ([]byte, error)

Just a stub, we don't want to write to database

type BatchDisableUsersCommand

type BatchDisableUsersCommand struct {
	UserIDs    []int64 `xorm:"user_ids"`
	IsDisabled bool
}

type ChangeUserPasswordCommand

type ChangeUserPasswordCommand struct {
	OldPassword string `json:"oldPassword"`
	NewPassword string `json:"newPassword"`

	UserID int64 `json:"-"`
}

type CreateUserCommand

type CreateUserCommand struct {
	Email            string
	Login            string
	Name             string
	Company          string
	OrgID            int64
	OrgName          string
	Password         string
	EmailVerified    bool
	IsAdmin          bool
	IsDisabled       bool
	SkipOrgSetup     bool
	DefaultOrgRole   string
	IsServiceAccount bool
}

type DeleteUserCommand

type DeleteUserCommand struct {
	UserID int64
}

type DisableUserCommand

type DisableUserCommand struct {
	UserID     int64 `xorm:"user_id"`
	IsDisabled bool
}

type ErrCaseInsensitiveLoginConflict

type ErrCaseInsensitiveLoginConflict struct {
	Users []User
}

func (*ErrCaseInsensitiveLoginConflict) Error

func (*ErrCaseInsensitiveLoginConflict) Unwrap

type Filter

type Filter interface {
	WhereCondition() *WhereCondition
	InCondition() *InCondition
	JoinCondition() *JoinCondition
}

type FilterHandler

type FilterHandler func(params []string) (Filter, error)

type GetSignedInUserQuery

type GetSignedInUserQuery struct {
	UserID int64 `xorm:"user_id"`
	Login  string
	Email  string
	OrgID  int64 `xorm:"org_id"`
}

type GetUserByEmailQuery

type GetUserByEmailQuery struct {
	Email string
}

type GetUserByIDQuery

type GetUserByIDQuery struct {
	ID int64
}

type GetUserByLoginQuery

type GetUserByLoginQuery struct {
	LoginOrEmail string
}

type GetUserProfileQuery

type GetUserProfileQuery struct {
	UserID int64
}

type HelpFlags1

type HelpFlags1 uint64
const (
	HelpFlagGettingStartedPanelDismissed HelpFlags1 = 1 << iota
	HelpFlagDashboardHelp1
)

func (*HelpFlags1) AddFlag

func (f *HelpFlags1) AddFlag(flag HelpFlags1)

func (HelpFlags1) HasFlag

func (f HelpFlags1) HasFlag(flag HelpFlags1) bool

type InCondition

type InCondition struct {
	Condition string
	Params    interface{}
}

type JoinCondition

type JoinCondition struct {
	Operator string
	Table    string
	Params   string
}

type Password

type Password string

func (Password) IsWeak

func (p Password) IsWeak() bool

type SearchUserFilter

type SearchUserFilter interface {
	GetFilter(filterName string, params []string) Filter
	GetFilterList() map[string]FilterHandler
}

type SearchUserQueryResult

type SearchUserQueryResult struct {
	TotalCount int64               `json:"totalCount"`
	Users      []*UserSearchHitDTO `json:"users"`
	Page       int                 `json:"page"`
	PerPage    int                 `json:"perPage"`
}

type SearchUsersQuery

type SearchUsersQuery struct {
	SignedInUser *SignedInUser
	OrgID        int64 `xorm:"org_id"`
	Query        string
	Page         int
	Limit        int
	AuthModule   string
	Filters      []Filter

	IsDisabled *bool
}

type SetUserHelpFlagCommand

type SetUserHelpFlagCommand struct {
	HelpFlags1 HelpFlags1
	UserID     int64 `xorm:"user_id"`
}

type SetUsingOrgCommand

type SetUsingOrgCommand struct {
	UserID int64
	OrgID  int64
}

type SignedInUser

type SignedInUser struct {
	UserID           int64 `xorm:"user_id"`
	OrgID            int64 `xorm:"org_id"`
	OrgName          string
	OrgRole          roletype.RoleType
	Login            string
	Name             string
	Email            string
	AuthenticatedBy  string
	ApiKeyID         int64 `xorm:"api_key_id"`
	IsServiceAccount bool  `xorm:"is_service_account"`
	IsGrafanaAdmin   bool
	IsAnonymous      bool
	IsDisabled       bool
	HelpFlags1       HelpFlags1
	LastSeenAt       time.Time
	Teams            []int64
	// Permissions grouped by orgID and actions
	Permissions map[int64]map[string][]string `json:"-"`
}

func (*SignedInUser) GetCacheKey

func (u *SignedInUser) GetCacheKey() (string, error)

GetCacheKey returns a unique key for the entity. Add an extra prefix to avoid collisions with other caches

func (*SignedInUser) GetDisplayName

func (u *SignedInUser) GetDisplayName() string

GetDisplayName returns the display name of the active entity The display name is the name if it is set, otherwise the login or email

func (*SignedInUser) GetEmail

func (u *SignedInUser) GetEmail() string

GetEmail returns the email of the active entity Can be empty.

func (*SignedInUser) GetIsGrafanaAdmin

func (u *SignedInUser) GetIsGrafanaAdmin() bool

GetIsGrafanaAdmin returns true if the user is a server admin

func (*SignedInUser) GetLogin

func (u *SignedInUser) GetLogin() string

GetLogin returns the login of the active entity Can be empty if the user is anonymous

func (*SignedInUser) GetNamespacedID

func (u *SignedInUser) GetNamespacedID() (string, string)

GetNamespacedID returns the namespace and ID of the active entity The namespace is one of the constants defined in pkg/services/auth/identity

func (*SignedInUser) GetOrgID

func (u *SignedInUser) GetOrgID() int64

GetOrgID returns the ID of the active organization

func (*SignedInUser) GetOrgName

func (u *SignedInUser) GetOrgName() string

DEPRECATED: GetOrgName returns the name of the active organization Retrieve the organization name from the organization service instead of using this method.

func (*SignedInUser) GetOrgRole

func (u *SignedInUser) GetOrgRole() roletype.RoleType

GetOrgRole returns the role of the active entity in the active organization

func (*SignedInUser) GetPermissions

func (u *SignedInUser) GetPermissions() map[string][]string

GetPermissions returns the permissions of the active entity

func (*SignedInUser) GetTeams

func (u *SignedInUser) GetTeams() []int64

DEPRECATED: GetTeams returns the teams the entity is a member of Retrieve the teams from the team service instead of using this method.

func (*SignedInUser) HasRole

func (u *SignedInUser) HasRole(role roletype.RoleType) bool

func (*SignedInUser) HasUniqueId

func (u *SignedInUser) HasUniqueId() bool

HasUniqueId returns true if the entity has a unique id

func (*SignedInUser) IsApiKeyUser

func (u *SignedInUser) IsApiKeyUser() bool

func (*SignedInUser) IsNil

func (u *SignedInUser) IsNil() bool

FIXME: remove this method once all services are using an interface

func (*SignedInUser) IsRealUser

func (u *SignedInUser) IsRealUser() bool

IsRealUser returns true if the entity is a real user and not a service account

func (*SignedInUser) IsServiceAccountUser

func (u *SignedInUser) IsServiceAccountUser() bool

IsServiceAccountUser returns true if the entity is a service account

func (*SignedInUser) NameOrFallback

func (u *SignedInUser) NameOrFallback() string

func (*SignedInUser) ShouldUpdateLastSeenAt

func (u *SignedInUser) ShouldUpdateLastSeenAt() bool

func (*SignedInUser) ToUserDisplayDTO

func (u *SignedInUser) ToUserDisplayDTO() *UserDisplayDTO

type UpdateUserCommand

type UpdateUserCommand struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Login string `json:"login"`
	Theme string `json:"theme"`

	UserID int64 `json:"-"`
}

type UpdateUserLastSeenAtCommand

type UpdateUserLastSeenAtCommand struct {
	UserID int64
	OrgID  int64
}

type User

type User struct {
	ID            int64 `xorm:"pk autoincr 'id'"`
	Version       int
	Email         string
	Name          string
	Login         string
	Password      string
	Salt          string
	Rands         string
	Company       string
	EmailVerified bool
	Theme         string
	HelpFlags1    HelpFlags1
	IsDisabled    bool

	IsAdmin          bool
	IsServiceAccount bool
	OrgID            int64 `xorm:"org_id"`

	Created    time.Time
	Updated    time.Time
	LastSeenAt time.Time
}

func (*User) NameOrFallback

func (u *User) NameOrFallback() string

type UserDisplayDTO

type UserDisplayDTO struct {
	ID        int64  `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	Login     string `json:"login,omitempty"`
	AvatarURL string `json:"avatarUrl"`
}

type UserProfileDTO

type UserProfileDTO struct {
	ID                             int64           `json:"id"`
	Email                          string          `json:"email"`
	Name                           string          `json:"name"`
	Login                          string          `json:"login"`
	Theme                          string          `json:"theme"`
	OrgID                          int64           `json:"orgId,omitempty"`
	IsGrafanaAdmin                 bool            `json:"isGrafanaAdmin"`
	IsDisabled                     bool            `json:"isDisabled"`
	IsExternal                     bool            `json:"isExternal"`
	IsExternallySynced             bool            `json:"isExternallySynced"`
	IsGrafanaAdminExternallySynced bool            `json:"isGrafanaAdminExternallySynced"`
	AuthLabels                     []string        `json:"authLabels"`
	UpdatedAt                      time.Time       `json:"updatedAt"`
	CreatedAt                      time.Time       `json:"createdAt"`
	AvatarURL                      string          `json:"avatarUrl"`
	AccessControl                  map[string]bool `json:"accessControl,omitempty"`
}

type UserSearchHitDTO

type UserSearchHitDTO struct {
	ID            int64                `json:"id" xorm:"id"`
	Name          string               `json:"name"`
	Login         string               `json:"login"`
	Email         string               `json:"email"`
	AvatarURL     string               `json:"avatarUrl" xorm:"avatar_url"`
	IsAdmin       bool                 `json:"isAdmin"`
	IsDisabled    bool                 `json:"isDisabled"`
	LastSeenAt    time.Time            `json:"lastSeenAt"`
	LastSeenAtAge string               `json:"lastSeenAtAge"`
	AuthLabels    []string             `json:"authLabels"`
	AuthModule    AuthModuleConversion `json:"-"`
}

type WhereCondition

type WhereCondition struct {
	Condition string
	Params    interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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