user

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GeneralNamespace = "*"

	AdminRole        = "admin"
	ProjectAdminRole = "project-admin"
	ReadOnlyRole     = "read-only"
)
View Source
const (
	// delivery
	VerbGetDelivery    = "get_delivery"
	VerbCreateDelivery = "create_delivery"
	VerbDeleteDelivery = "delete_delivery"
	// test
	VerbGetTest    = "get_test"
	VerbCreateTest = "create_test"
	VerbEditTest   = "edit_test"
	VerbDeleteTest = "delete_test"
	VerbRunTest    = "run_test"
	// service
	VerbGetService    = "get_service"
	VerbCreateService = "create_service"
	VerbEditService   = "edit_service"
	VerbDeleteService = "delete_service"
	// production service
	VerbGetProductionService    = "get_production_service"
	VerbCreateProductionService = "create_production_service"
	VerbEditProductionService   = "edit_production_service"
	VerbDeleteProductionService = "delete_production_service"
	// build
	VerbGetBuild    = "get_build"
	VerbCreateBuild = "create_build"
	VerbEditBuild   = "edit_build"
	VerbDeleteBuild = "delete_build"
	// Workflow
	VerbGetWorkflow    = "get_workflow"
	VerbCreateWorkflow = "create_workflow"
	VerbEditWorkflow   = "edit_workflow"
	VerbDeleteWorkflow = "delete_workflow"
	VerbRunWorkflow    = "run_workflow"
	VerbDebugWorkflow  = "debug_workflow"
	// Environment
	VerbGetEnvironment      = "get_environment"
	VerbCreateEnvironment   = "create_environment"
	VerbConfigEnvironment   = "config_environment"
	VerbManageEnvironment   = "manage_environment"
	VerbDeleteEnvironment   = "delete_environment"
	VerbDebugEnvironmentPod = "debug_pod"
	VerbEnvironmentSSHPM    = "ssh_pm"
	// Production Environment
	VerbGetProductionEnv      = "get_production_environment"
	VerbCreateProductionEnv   = "create_production_environment"
	VerbConfigProductionEnv   = "config_production_environment"
	VerbEditProductionEnv     = "edit_production_environment"
	VerbDeleteProductionEnv   = "delete_production_environment"
	VerbDebugProductionEnvPod = "production_debug_pod"
	// Scanning
	VerbGetScan    = "get_scan"
	VerbCreateScan = "create_scan"
	VerbEditScan   = "edit_scan"
	VerbDeleteScan = "delete_scan"
	VerbRunScan    = "run_scan"
)

Namespaced Resources Actions

View Source
const (
	// project
	VerbCreateProject = "create_project"
	VerbDeleteProject = "delete_project"
	// template store
	VerbCreateTemplate = "create_template"
	VerbGetTemplate    = "get_template"
	VerbEditTemplate   = "edit_template"
	VerbDeleteTemplate = "delete_template"
	// test center
	VerbViewTestCenter = "get_test"
	// release center
	VerbViewReleaseCenter = "get_release"
	// delivery center
	VerbDeliveryCenterGetVersions = "release_get"
	VerbDeliveryCenterGetArtifact = "delivery_get"
	// data center
	VerbGetDataCenterOverview       = "data_over"
	VerbGetDataCenterInsight        = "efficiency_over"
	VerbEditDataCenterInsightConfig = "edit_dashboard_config"
)

system level authorization actions

View Source
const (
	UppercaseValidator = `[A-Z]+`
	LowercaseValidator = `[a-z]+`
	DigitValidator     = `\d+`
	LengthValidator    = `.{8,}`
)

Variables

This section is empty.

Functions

func CheckCollaborationModePermission added in v1.18.0

func CheckCollaborationModePermission(uid, projectKey, resource, resourceName, action string) (hasPermission bool, err error)

func CheckPermissionGivenByCollaborationMode added in v1.18.0

func CheckPermissionGivenByCollaborationMode(uid, projectKey, resource, action string) (hasPermission bool, err error)

func CreateUser

func CreateUser(args *User, logger *zap.SugaredLogger) (*models.User, error)

func DeleteUserByUID

func DeleteUserByUID(uid string, logger *zap.SugaredLogger) error

func GetUser

func GetUser(uid string, logger *zap.SugaredLogger) (*types.UserInfo, error)

func GetUserCount added in v1.9.9

func GetUserCount(logger *zap.SugaredLogger) (*types.UserStatistics, error)

func GetUserSetting added in v1.9.9

func GetUserSetting(uid string, logger *zap.SugaredLogger) (*types.UserSetting, error)

func InitializeAdmin added in v1.18.0

func InitializeAdmin() error

func ListAuthorizedEnvs added in v1.18.0

func ListAuthorizedEnvs(uid, projectKey string, logger *zap.SugaredLogger) (readEnvList, editEnvList []string, err error)

func ListAuthorizedProject added in v1.18.0

func ListAuthorizedProject(uid string, logger *zap.SugaredLogger) ([]string, error)

func ListAuthorizedProjectByVerb added in v1.18.0

func ListAuthorizedProjectByVerb(uid, resource, verb string, logger *zap.SugaredLogger) ([]string, error)

func ListAuthorizedWorkflow added in v1.18.0

func ListAuthorizedWorkflow(uid, projectKey string, logger *zap.SugaredLogger) ([]string, []string, error)

ListAuthorizedWorkflow lists all workflows authorized by collaboration mode

func Reset

func Reset(args *ResetParams, logger *zap.SugaredLogger) error

func SearchAndSyncUser

func SearchAndSyncUser(ldapId string, logger *zap.SugaredLogger) error

func SearchUserByAccount

func SearchUserByAccount(args *QueryArgs, logger *zap.SugaredLogger) (*types.UsersResp, error)

func SearchUsers

func SearchUsers(args *QueryArgs, logger *zap.SugaredLogger) (*types.UsersResp, error)

func SearchUsersByUIDs

func SearchUsersByUIDs(uids []string, logger *zap.SugaredLogger) (*types.UsersResp, error)

func SyncUser

func SyncUser(syncUserInfo *SyncUserInfo, ifUpdateLoginTime bool, logger *zap.SugaredLogger) (*models.User, error)

func UpdatePassword

func UpdatePassword(args *Password, logger *zap.SugaredLogger) error

func UpdateUser

func UpdateUser(uid string, args *UpdateUserInfo, _ *zap.SugaredLogger) error

func UpdateUserSetting added in v1.9.9

func UpdateUserSetting(uid string, args *UserSetting) error

Types

type AuthorizedResources added in v1.18.0

type AuthorizedResources struct {
	IsSystemAdmin   bool                      `json:"is_system_admin"`
	ProjectAuthInfo map[string]ProjectActions `json:"project_auth_info"`
	SystemActions   *SystemActions            `json:"system_actions"`
}

func GetUserAuthInfo added in v1.18.0

func GetUserAuthInfo(uid string, logger *zap.SugaredLogger) (*AuthorizedResources, error)

type BuildActions added in v1.18.0

type BuildActions struct {
	View   bool
	Create bool
	Edit   bool
	Delete bool
}

type DataCenterActions added in v1.18.0

type DataCenterActions struct {
	ViewOverView      bool
	ViewInsight       bool
	EditInsightConfig bool
}

type DeliveryCenterActions added in v1.18.0

type DeliveryCenterActions struct {
	ViewArtifact bool
	ViewVersion  bool
}

type EnvActions added in v1.18.0

type EnvActions struct {
	View   bool
	Create bool
	// 配置
	EditConfig bool
	// 管理服务实例
	ManagePods bool
	Delete     bool
	DebugPod   bool
	// 主机登录
	SSH bool
}

type Operation added in v1.18.0

type Operation struct {
	Data string `json:"data"`
}

type Password

type Password struct {
	Uid         string `json:"uid"`
	OldPassword string `json:"oldPassword"`
	NewPassword string `json:"newPassword"`
}

type ProductionEnvActions added in v1.18.0

type ProductionEnvActions struct {
	View   bool
	Create bool
	// 配置
	EditConfig bool
	// 管理服务实例
	ManagePods bool
	Delete     bool
	DebugPod   bool
}

type ProductionServiceActions added in v1.18.0

type ProductionServiceActions struct {
	View   bool
	Create bool
	Edit   bool
	Delete bool
}

type ProjectActions added in v1.18.0

type ProjectActions struct {
	IsProjectAdmin    bool                      `json:"is_system_admin"`
	Workflow          *WorkflowActions          `json:"workflow"`
	Env               *EnvActions               `json:"env"`
	ProductionEnv     *ProductionEnvActions     `json:"production_env"`
	Service           *ServiceActions           `json:"service"`
	ProductionService *ProductionServiceActions `json:"production_service"`
	Build             *BuildActions             `json:"build"`
	Test              *TestActions              `json:"test"`
	Scanning          *ScanningActions          `json:"scanning"`
	Version           *VersionActions           `json:"version"`
}

type QueryArgs

type QueryArgs struct {
	Name         string   `json:"name,omitempty"`
	Account      string   `json:"account,omitempty"`
	IdentityType string   `json:"identity_type,omitempty"`
	UIDs         []string `json:"uids,omitempty"`
	PerPage      int      `json:"per_page,omitempty"`
	Page         int      `json:"page,omitempty"`
}

type Register added in v1.18.0

type Register struct {
	Domain    string `json:"domain"`
	Username  string `json:"username"`
	Email     string `json:"email"`
	CreatedAt int64  `json:"created_at"`
}

type ReleaseCenterActions added in v1.18.0

type ReleaseCenterActions struct {
	View bool
}

type ResetParams

type ResetParams struct {
	Uid      string `json:"uid"`
	Password string `json:"password"`
}

type RetrieveResp

type RetrieveResp struct {
	Email string `json:"email"`
}

func Retrieve

func Retrieve(account string, logger *zap.SugaredLogger) (*RetrieveResp, error)

type ScanningActions added in v1.18.0

type ScanningActions struct {
	View    bool
	Create  bool
	Edit    bool
	Delete  bool
	Execute bool
}

type ServiceActions added in v1.18.0

type ServiceActions struct {
	View   bool
	Create bool
	Edit   bool
	Delete bool
}

type SyncUserInfo

type SyncUserInfo struct {
	Account      string `json:"account"`
	IdentityType string `json:"identityType"`
	Name         string `json:"name"`
	Email        string `json:"email"`
}

type SystemActions added in v1.18.0

type SystemActions struct {
	Project        *SystemProjectActions  `json:"project"`
	Template       *TemplateActions       `json:"template"`
	TestCenter     *TestCenterActions     `json:"test_center"`
	ReleaseCenter  *ReleaseCenterActions  `json:"release_center"`
	DeliveryCenter *DeliveryCenterActions `json:"delivery_center"`
	DataCenter     *DataCenterActions     `json:"data_center"`
}

type SystemProjectActions added in v1.18.0

type SystemProjectActions struct {
	Create bool
	Delete bool
}

type TemplateActions added in v1.18.0

type TemplateActions struct {
	Create bool
	View   bool
	Edit   bool
	Delete bool
}

type TestActions added in v1.18.0

type TestActions struct {
	View    bool
	Create  bool
	Edit    bool
	Delete  bool
	Execute bool
}

type TestCenterActions added in v1.18.0

type TestCenterActions struct {
	View bool
}

type UpdateUserInfo

type UpdateUserInfo struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
	Phone string `json:"phone,omitempty"`
}

type User

type User struct {
	Name     string `json:"name"`
	Password string `json:"password"`
	Email    string `json:"email"`
	Account  string `json:"account"`
	Phone    string `json:"phone,omitempty"`
}

type UserSetting added in v1.9.9

type UserSetting struct {
	Theme        string `json:"theme"`
	LogBgColor   string `json:"log_bg_color"`
	LogFontColor string `json:"log_font_color"`
}

type VersionActions added in v1.18.0

type VersionActions struct {
	View   bool
	Create bool
	Delete bool
}

type WorkflowActions added in v1.18.0

type WorkflowActions struct {
	View    bool
	Create  bool
	Edit    bool
	Delete  bool
	Execute bool
	Debug   bool
}

Jump to

Keyboard shortcuts

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