Documentation
¶
Index ¶
- Constants
- Variables
- type AdminCreateUserResponse
- type AnalyticsSettings
- type AuthModuleConversion
- type BatchDisableUsersCommand
- type ChangeUserPasswordCommand
- type CreateUserCommand
- type DeleteUserCommand
- type DisableUserCommand
- type ErrCaseInsensitiveLoginConflict
- type Filter
- type FilterHandler
- type GetSignedInUserQuery
- type GetUserByEmailQuery
- type GetUserByIDQuery
- type GetUserByLoginQuery
- type GetUserProfileQuery
- type HelpFlags1
- type InCondition
- type JoinCondition
- type Password
- type SearchUserFilter
- type SearchUserQueryResult
- type SearchUsersQuery
- type Service
- type SetUserHelpFlagCommand
- type SetUsingOrgCommand
- type SignedInUser
- func (u *SignedInUser) GetCacheKey() (string, error)
- func (u *SignedInUser) GetDisplayName() string
- func (u *SignedInUser) GetEmail() string
- func (u *SignedInUser) GetIsGrafanaAdmin() bool
- func (u *SignedInUser) GetLogin() string
- func (u *SignedInUser) GetNamespacedID() (string, string)
- func (u *SignedInUser) GetOrgID() int64
- func (u *SignedInUser) GetOrgName() string
- func (u *SignedInUser) GetOrgRole() roletype.RoleType
- func (u *SignedInUser) GetPermissions() map[string][]string
- func (u *SignedInUser) GetTeams() []int64
- func (u *SignedInUser) HasRole(role roletype.RoleType) bool
- func (u *SignedInUser) HasUniqueId() bool
- func (u *SignedInUser) IsApiKeyUser() bool
- func (u *SignedInUser) IsNil() bool
- func (u *SignedInUser) IsRealUser() bool
- func (u *SignedInUser) IsServiceAccountUser() bool
- func (u *SignedInUser) NameOrFallback() string
- func (u *SignedInUser) ShouldUpdateLastSeenAt() bool
- func (u *SignedInUser) ToUserDisplayDTO() *UserDisplayDTO
- type UpdateUserCommand
- type UpdateUserLastSeenAtCommand
- type User
- type UserDisplayDTO
- type UserProfileDTO
- type UserSearchHitDTO
- type WhereCondition
Constants ¶
const ( QuotaTargetSrv string = "user" QuotaTarget string = "user" )
Variables ¶
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 AnalyticsSettings ¶
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 CreateUserCommand ¶
type DeleteUserCommand ¶
type DeleteUserCommand struct {
UserID int64
}
type DisableUserCommand ¶
type ErrCaseInsensitiveLoginConflict ¶
type ErrCaseInsensitiveLoginConflict struct {
Users []User
}
func (*ErrCaseInsensitiveLoginConflict) Error ¶
func (e *ErrCaseInsensitiveLoginConflict) Error() string
func (*ErrCaseInsensitiveLoginConflict) Unwrap ¶
func (e *ErrCaseInsensitiveLoginConflict) Unwrap() error
type Filter ¶
type Filter interface { WhereCondition() *WhereCondition InCondition() *InCondition JoinCondition() *JoinCondition }
type FilterHandler ¶
type GetSignedInUserQuery ¶
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 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 Service ¶
type Service interface { registry.ProvidesUsageStats Create(context.Context, *CreateUserCommand) (*User, error) CreateServiceAccount(context.Context, *CreateUserCommand) (*User, error) Delete(context.Context, *DeleteUserCommand) error GetByID(context.Context, *GetUserByIDQuery) (*User, error) GetByLogin(context.Context, *GetUserByLoginQuery) (*User, error) GetByEmail(context.Context, *GetUserByEmailQuery) (*User, error) Update(context.Context, *UpdateUserCommand) error ChangePassword(context.Context, *ChangeUserPasswordCommand) error UpdateLastSeenAt(context.Context, *UpdateUserLastSeenAtCommand) error SetUsingOrg(context.Context, *SetUsingOrgCommand) error GetSignedInUserWithCacheCtx(context.Context, *GetSignedInUserQuery) (*SignedInUser, error) GetSignedInUser(context.Context, *GetSignedInUserQuery) (*SignedInUser, error) NewAnonymousSignedInUser(context.Context) (*SignedInUser, error) Search(context.Context, *SearchUsersQuery) (*SearchUserQueryResult, error) Disable(context.Context, *DisableUserCommand) error BatchDisableUsers(context.Context, *BatchDisableUsersCommand) error UpdatePermissions(context.Context, int64, bool) error SetUserHelpFlag(context.Context, *SetUserHelpFlagCommand) error GetProfile(context.Context, *GetUserProfileQuery) (*UserProfileDTO, error) }
type SetUserHelpFlagCommand ¶
type SetUserHelpFlagCommand struct { HelpFlags1 HelpFlags1 UserID int64 `xorm:"user_id"` }
type SetUsingOrgCommand ¶
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) 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 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 ¶
type UserDisplayDTO ¶
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{} }