repository

package
v0.0.0-...-987a61a Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

@description: user crud

@description: user authentication and authorization

@description: user crud

Index

Constants

View Source
const (
	PROJECT_TYPE     = "team"
	ENV_TYPE         = "environment"
	APP_TYPE         = "app"
	CHART_GROUP_TYPE = "chart-group"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultAuthPolicy

type DefaultAuthPolicy struct {
	TableName struct{} `sql:"default_auth_policy" pg:",discard_unknown_columns"`
	Id        int      `sql:"id,pk"`
	RoleType  string   `sql:"role_type,notnull"`
	Policy    string   `sql:"policy,notnull"`
	sql.AuditLog
}

type DefaultAuthPolicyRepository

type DefaultAuthPolicyRepository interface {
	CreatePolicy(policy *DefaultAuthPolicy) (*DefaultAuthPolicy, error)
	UpdatePolicyByRoleType(policy string, roleType RoleType) (*DefaultAuthPolicy, error)
	GetPolicyByRoleType(roleType RoleType) (policy string, err error)
}

type DefaultAuthPolicyRepositoryImpl

type DefaultAuthPolicyRepositoryImpl struct {
	// contains filtered or unexported fields
}

func NewDefaultAuthPolicyRepositoryImpl

func NewDefaultAuthPolicyRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger) *DefaultAuthPolicyRepositoryImpl

func (DefaultAuthPolicyRepositoryImpl) CreatePolicy

func (DefaultAuthPolicyRepositoryImpl) GetPolicyByRoleType

func (impl DefaultAuthPolicyRepositoryImpl) GetPolicyByRoleType(roleType RoleType) (policy string, err error)

func (DefaultAuthPolicyRepositoryImpl) UpdatePolicyByRoleType

func (impl DefaultAuthPolicyRepositoryImpl) UpdatePolicyByRoleType(policy string, roleType RoleType) (*DefaultAuthPolicy, error)

type DefaultAuthRole

type DefaultAuthRole struct {
	TableName struct{} `sql:"default_auth_role" pg:",discard_unknown_columns"`
	Id        int      `sql:"id,pk"`
	RoleType  string   `sql:"role_type,notnull"`
	Role      string   `sql:"role,notnull"`
	sql.AuditLog
}

type DefaultAuthRoleRepository

type DefaultAuthRoleRepository interface {
	CreateRole(role *DefaultAuthRole) (*DefaultAuthRole, error)
	UpdateRole(role *DefaultAuthRole) (*DefaultAuthRole, error)
	GetRoleByRoleType(roleType RoleType) (role string, err error)
}

type DefaultAuthRoleRepositoryImpl

type DefaultAuthRoleRepositoryImpl struct {
	// contains filtered or unexported fields
}

func NewDefaultAuthRoleRepositoryImpl

func NewDefaultAuthRoleRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger) *DefaultAuthRoleRepositoryImpl

func (DefaultAuthRoleRepositoryImpl) CreateRole

func (DefaultAuthRoleRepositoryImpl) GetRoleByRoleType

func (impl DefaultAuthRoleRepositoryImpl) GetRoleByRoleType(roleType RoleType) (role string, err error)

func (DefaultAuthRoleRepositoryImpl) UpdateRole

type RoleGroup

type RoleGroup struct {
	TableName   struct{} `sql:"role_group" pg:",discard_unknown_columns"`
	Id          int32    `sql:"id,pk"`
	Name        string   `sql:"name,notnull"`
	CasbinName  string   `sql:"casbin_name,notnull"`
	Description string   `sql:"description"`
	Active      bool     `sql:"active,notnull"`
	sql.AuditLog
}

type RoleGroupRepository

type RoleGroupRepository interface {
	CreateRoleGroup(model *RoleGroup, tx *pg.Tx) (*RoleGroup, error)
	UpdateRoleGroup(model *RoleGroup, tx *pg.Tx) (*RoleGroup, error)
	GetRoleGroupById(id int32) (*RoleGroup, error)
	GetRoleGroupByName(name string) (*RoleGroup, error)
	GetRoleGroupListByName(name string) ([]*RoleGroup, error)
	GetAllRoleGroup() ([]*RoleGroup, error)
	GetRoleGroupListByCasbinNames(name []string) ([]*RoleGroup, error)

	CreateRoleGroupRoleMapping(model *RoleGroupRoleMapping, tx *pg.Tx) (*RoleGroupRoleMapping, error)
	GetRoleGroupRoleMapping(model int32) (*RoleGroupRoleMapping, error)
	GetRoleGroupRoleMappingByRoleGroupId(roleGroupId int32) ([]*RoleGroupRoleMapping, error)
	DeleteRoleGroupRoleMappingByRoleId(roleId int, tx *pg.Tx) error
	DeleteRoleGroupRoleMapping(model *RoleGroupRoleMapping, tx *pg.Tx) (bool, error)
	GetConnection() (dbConnection *pg.DB)
	GetRoleGroupListByNames(groupNames []string) ([]*RoleGroup, error)
	GetRoleGroupRoleMappingByRoleGroupIds(roleGroupIds []int32) ([]*RoleModel, error)
}

type RoleGroupRepositoryImpl

type RoleGroupRepositoryImpl struct {
	Logger *zap.SugaredLogger
	// contains filtered or unexported fields
}

func NewRoleGroupRepositoryImpl

func NewRoleGroupRepositoryImpl(dbConnection *pg.DB, Logger *zap.SugaredLogger) *RoleGroupRepositoryImpl

func (RoleGroupRepositoryImpl) CreateRoleGroup

func (impl RoleGroupRepositoryImpl) CreateRoleGroup(model *RoleGroup, tx *pg.Tx) (*RoleGroup, error)

func (RoleGroupRepositoryImpl) CreateRoleGroupRoleMapping

func (impl RoleGroupRepositoryImpl) CreateRoleGroupRoleMapping(model *RoleGroupRoleMapping, tx *pg.Tx) (*RoleGroupRoleMapping, error)

func (RoleGroupRepositoryImpl) DeleteRoleGroupRoleMapping

func (impl RoleGroupRepositoryImpl) DeleteRoleGroupRoleMapping(model *RoleGroupRoleMapping, tx *pg.Tx) (bool, error)

func (RoleGroupRepositoryImpl) DeleteRoleGroupRoleMappingByRoleId

func (impl RoleGroupRepositoryImpl) DeleteRoleGroupRoleMappingByRoleId(roleId int, tx *pg.Tx) error

func (RoleGroupRepositoryImpl) GetAllRoleGroup

func (impl RoleGroupRepositoryImpl) GetAllRoleGroup() ([]*RoleGroup, error)

func (*RoleGroupRepositoryImpl) GetConnection

func (impl *RoleGroupRepositoryImpl) GetConnection() (dbConnection *pg.DB)

func (RoleGroupRepositoryImpl) GetRoleGroupById

func (impl RoleGroupRepositoryImpl) GetRoleGroupById(id int32) (*RoleGroup, error)

func (RoleGroupRepositoryImpl) GetRoleGroupByName

func (impl RoleGroupRepositoryImpl) GetRoleGroupByName(name string) (*RoleGroup, error)

func (RoleGroupRepositoryImpl) GetRoleGroupListByCasbinNames

func (impl RoleGroupRepositoryImpl) GetRoleGroupListByCasbinNames(names []string) ([]*RoleGroup, error)

func (RoleGroupRepositoryImpl) GetRoleGroupListByName

func (impl RoleGroupRepositoryImpl) GetRoleGroupListByName(name string) ([]*RoleGroup, error)

func (RoleGroupRepositoryImpl) GetRoleGroupListByNames

func (impl RoleGroupRepositoryImpl) GetRoleGroupListByNames(groupNames []string) ([]*RoleGroup, error)

func (RoleGroupRepositoryImpl) GetRoleGroupRoleMapping

func (impl RoleGroupRepositoryImpl) GetRoleGroupRoleMapping(userRoleModelId int32) (*RoleGroupRoleMapping, error)

func (RoleGroupRepositoryImpl) GetRoleGroupRoleMappingByRoleGroupId

func (impl RoleGroupRepositoryImpl) GetRoleGroupRoleMappingByRoleGroupId(roleGroupId int32) ([]*RoleGroupRoleMapping, error)

func (RoleGroupRepositoryImpl) GetRoleGroupRoleMappingByRoleGroupIds

func (impl RoleGroupRepositoryImpl) GetRoleGroupRoleMappingByRoleGroupIds(roleGroupIds []int32) ([]*RoleModel, error)

func (RoleGroupRepositoryImpl) UpdateRoleGroup

func (impl RoleGroupRepositoryImpl) UpdateRoleGroup(model *RoleGroup, tx *pg.Tx) (*RoleGroup, error)

type RoleGroupRoleMapping

type RoleGroupRoleMapping struct {
	TableName   struct{} `sql:"role_group_role_mapping"  pg:",discard_unknown_columns"`
	Id          int      `sql:"id,pk"`
	RoleGroupId int32    `sql:"role_group_id,notnull"`
	RoleId      int      `sql:"role_id,notnull"`
	sql.AuditLog
}

type RoleModel

type RoleModel struct {
	TableName   struct{} `sql:"roles" pg:",discard_unknown_columns"`
	Id          int      `sql:"id,pk"`
	Role        string   `sql:"role,notnull"`
	Entity      string   `sql:"entity"`
	Team        string   `sql:"team"`
	EntityName  string   `sql:"entity_name"`
	Environment string   `sql:"environment"`
	Action      string   `sql:"action"`
	AccessType  string   `sql:"access_type"`
	sql.AuditLog
}

type RolePolicyDetails

type RolePolicyDetails struct {
	Team       string
	Env        string
	App        string
	TeamObj    string
	EnvObj     string
	AppObj     string
	Entity     string
	EntityName string
}

type RoleType

type RoleType string
const (
	MANAGER_TYPE               RoleType = "manager"
	ADMIN_TYPE                 RoleType = "admin"
	TRIGGER_TYPE               RoleType = "trigger"
	VIEW_TYPE                  RoleType = "view"
	ENTITY_ALL_TYPE            RoleType = "entityAll"
	ENTITY_VIEW_TYPE           RoleType = "entityView"
	ENTITY_SPECIFIC_TYPE       RoleType = "entitySpecific"
	ENTITY_SPECIFIC_ADMIN_TYPE RoleType = "entitySpecificAdmin"
	ENTITY_SPECIFIC_VIEW_TYPE  RoleType = "entitySpecificView"
	ROLE_SPECIFIC_TYPE         RoleType = "roleSpecific"
)

type SelfRegistrationRoles

type SelfRegistrationRoles struct {
	TableName struct{} `sql:"self_registration_roles" pg:",discard_unknown_columns"`
	Role      string   `sql:"role,notnull"`
	sql.AuditLog
}

type SelfRegistrationRolesRepository

type SelfRegistrationRolesRepository interface {
	GetAll() ([]SelfRegistrationRoles, error)
}

type SelfRegistrationRolesRepositoryImpl

type SelfRegistrationRolesRepositoryImpl struct {
	// contains filtered or unexported fields
}

func NewSelfRegistrationRolesRepositoryImpl

func NewSelfRegistrationRolesRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger) *SelfRegistrationRolesRepositoryImpl

func (*SelfRegistrationRolesRepositoryImpl) GetAll

type UserAudit

type UserAudit struct {
	TableName struct{}  `sql:"user_audit"`
	Id        int32     `sql:"id,pk"`
	UserId    int32     `sql:"user_id, notnull"`
	ClientIp  string    `sql:"client_ip"`
	CreatedOn time.Time `sql:"created_on,type:timestamptz"`
}

type UserAuditRepository

type UserAuditRepository interface {
	Save(userAudit *UserAudit) error
	GetLatestByUserId(userId int32) (*UserAudit, error)
}

type UserAuditRepositoryImpl

type UserAuditRepositoryImpl struct {
	// contains filtered or unexported fields
}

func NewUserAuditRepositoryImpl

func NewUserAuditRepositoryImpl(dbConnection *pg.DB) *UserAuditRepositoryImpl

func (UserAuditRepositoryImpl) GetLatestByUserId

func (impl UserAuditRepositoryImpl) GetLatestByUserId(userId int32) (*UserAudit, error)

func (UserAuditRepositoryImpl) Save

func (impl UserAuditRepositoryImpl) Save(userAudit *UserAudit) error

type UserAuthRepository

type UserAuthRepository interface {
	CreateRole(userModel *RoleModel, tx *pg.Tx) (*RoleModel, error)
	GetRoleById(id int) (*RoleModel, error)
	GetRoleByRoles(roles []string) ([]RoleModel, error)
	GetRolesByUserId(userId int32) ([]RoleModel, error)
	GetRolesByGroupId(userId int32) ([]*RoleModel, error)
	GetAllRole() ([]RoleModel, error)
	GetRolesByActionAndAccessType(action string, accessType string) ([]RoleModel, error)
	GetRoleByFilter(entity string, team string, app string, env string, act string, accessType string) (RoleModel, error)
	CreateUserRoleMapping(userRoleModel *UserRoleModel, tx *pg.Tx) (*UserRoleModel, error)
	GetUserRoleMappingByUserId(userId int32) ([]*UserRoleModel, error)
	DeleteUserRoleMapping(userRoleModel *UserRoleModel, tx *pg.Tx) (bool, error)
	DeleteUserRoleByRoleId(roleId int, tx *pg.Tx) error

	CreateDefaultPolicies(team string, entityName string, env string, tx *pg.Tx) (bool, error)
	CreateDefaultHelmPolicies(team string, entityName string, env string, tx *pg.Tx) (bool, error)
	CreateDefaultPoliciesForGlobalEntity(entity string, entityName string, action string, tx *pg.Tx) (bool, error)
	CreateRoleForSuperAdminIfNotExists(tx *pg.Tx) (bool, error)
	SyncOrchestratorToCasbin(team string, entityName string, env string, tx *pg.Tx) (bool, error)
	UpdateTriggerPolicyForTerminalAccess() error
	GetRolesForEnvironment(envName, envIdentifier string) ([]*RoleModel, error)
	GetRolesForProject(teamName string) ([]*RoleModel, error)
	GetRolesForApp(appName string) ([]*RoleModel, error)
	GetRolesForChartGroup(chartGroupName string) ([]*RoleModel, error)
	DeleteRole(role *RoleModel, tx *pg.Tx) error
}

type UserAuthRepositoryImpl

type UserAuthRepositoryImpl struct {
	Logger *zap.SugaredLogger
	// contains filtered or unexported fields
}

func NewUserAuthRepositoryImpl

func NewUserAuthRepositoryImpl(dbConnection *pg.DB, Logger *zap.SugaredLogger,
	defaultAuthPolicyRepository DefaultAuthPolicyRepository,
	defaultAuthRoleRepository DefaultAuthRoleRepository) *UserAuthRepositoryImpl

func (UserAuthRepositoryImpl) CreateDefaultHelmPolicies

func (impl UserAuthRepositoryImpl) CreateDefaultHelmPolicies(team string, entityName string, env string, tx *pg.Tx) (bool, error)

func (UserAuthRepositoryImpl) CreateDefaultPolicies

func (impl UserAuthRepositoryImpl) CreateDefaultPolicies(team string, entityName string, env string, tx *pg.Tx) (bool, error)

func (UserAuthRepositoryImpl) CreateDefaultPoliciesForGlobalEntity

func (impl UserAuthRepositoryImpl) CreateDefaultPoliciesForGlobalEntity(entity string, entityName string, action string, tx *pg.Tx) (bool, error)

func (UserAuthRepositoryImpl) CreateRole

func (impl UserAuthRepositoryImpl) CreateRole(userModel *RoleModel, tx *pg.Tx) (*RoleModel, error)

func (UserAuthRepositoryImpl) CreateRoleForSuperAdminIfNotExists

func (impl UserAuthRepositoryImpl) CreateRoleForSuperAdminIfNotExists(tx *pg.Tx) (bool, error)

func (UserAuthRepositoryImpl) CreateUserRoleMapping

func (impl UserAuthRepositoryImpl) CreateUserRoleMapping(userRoleModel *UserRoleModel, tx *pg.Tx) (*UserRoleModel, error)

func (UserAuthRepositoryImpl) DeleteRole

func (impl UserAuthRepositoryImpl) DeleteRole(role *RoleModel, tx *pg.Tx) error

func (UserAuthRepositoryImpl) DeleteUserRoleByRoleId

func (impl UserAuthRepositoryImpl) DeleteUserRoleByRoleId(roleId int, tx *pg.Tx) error

func (UserAuthRepositoryImpl) DeleteUserRoleMapping

func (impl UserAuthRepositoryImpl) DeleteUserRoleMapping(userRoleModel *UserRoleModel, tx *pg.Tx) (bool, error)

func (UserAuthRepositoryImpl) GetAllRole

func (impl UserAuthRepositoryImpl) GetAllRole() ([]RoleModel, error)

func (UserAuthRepositoryImpl) GetDefaultPolicyByRoleType

func (impl UserAuthRepositoryImpl) GetDefaultPolicyByRoleType(roleType RoleType) (policy string, err error)

func (UserAuthRepositoryImpl) GetDiffBetweenPolicies

func (impl UserAuthRepositoryImpl) GetDiffBetweenPolicies(oldPolicy string, newPolicy string) (addedPolicies []casbin.Policy, deletedPolicies []casbin.Policy, err error)

func (UserAuthRepositoryImpl) GetRole

func (impl UserAuthRepositoryImpl) GetRole(role string) (*RoleModel, error)

func (UserAuthRepositoryImpl) GetRoleByFilter

func (impl UserAuthRepositoryImpl) GetRoleByFilter(entity string, team string, app string, env string, act string, accessType string) (RoleModel, error)

func (UserAuthRepositoryImpl) GetRoleById

func (impl UserAuthRepositoryImpl) GetRoleById(id int) (*RoleModel, error)

func (UserAuthRepositoryImpl) GetRoleByRoles

func (impl UserAuthRepositoryImpl) GetRoleByRoles(roles []string) ([]RoleModel, error)

func (UserAuthRepositoryImpl) GetRolesByActionAndAccessType

func (impl UserAuthRepositoryImpl) GetRolesByActionAndAccessType(action string, accessType string) ([]RoleModel, error)

func (UserAuthRepositoryImpl) GetRolesByGroupId

func (impl UserAuthRepositoryImpl) GetRolesByGroupId(roleGroupId int32) ([]*RoleModel, error)

func (UserAuthRepositoryImpl) GetRolesByUserId

func (impl UserAuthRepositoryImpl) GetRolesByUserId(userId int32) ([]RoleModel, error)

func (UserAuthRepositoryImpl) GetRolesForApp

func (impl UserAuthRepositoryImpl) GetRolesForApp(appName string) ([]*RoleModel, error)

func (UserAuthRepositoryImpl) GetRolesForChartGroup

func (impl UserAuthRepositoryImpl) GetRolesForChartGroup(chartGroupName string) ([]*RoleModel, error)

func (UserAuthRepositoryImpl) GetRolesForEnvironment

func (impl UserAuthRepositoryImpl) GetRolesForEnvironment(envName, envIdentifier string) ([]*RoleModel, error)

func (UserAuthRepositoryImpl) GetRolesForProject

func (impl UserAuthRepositoryImpl) GetRolesForProject(teamName string) ([]*RoleModel, error)

func (UserAuthRepositoryImpl) GetUpdatedAddedOrDeletedPolicies

func (impl UserAuthRepositoryImpl) GetUpdatedAddedOrDeletedPolicies(policies []casbin.Policy, rolePolicyDetails RolePolicyDetails) (bean.PolicyRequest, error)

func (UserAuthRepositoryImpl) GetUserRoleMappingByUserId

func (impl UserAuthRepositoryImpl) GetUserRoleMappingByUserId(userId int32) ([]*UserRoleModel, error)

func (UserAuthRepositoryImpl) SyncOrchestratorToCasbin

func (impl UserAuthRepositoryImpl) SyncOrchestratorToCasbin(team string, entityName string, env string, tx *pg.Tx) (bool, error)

func (UserAuthRepositoryImpl) UpdateDefaultPolicyByRoleType

func (impl UserAuthRepositoryImpl) UpdateDefaultPolicyByRoleType(newPolicy string, roleType RoleType) (err error)

func (UserAuthRepositoryImpl) UpdateTriggerPolicyForTerminalAccess

func (impl UserAuthRepositoryImpl) UpdateTriggerPolicyForTerminalAccess() (err error)

type UserModel

type UserModel struct {
	TableName   struct{} `sql:"users"`
	Id          int32    `sql:"id,pk"`
	EmailId     string   `sql:"email_id,notnull"`
	AccessToken string   `sql:"access_token"`
	Active      bool     `sql:"active,notnull"`
	UserType    string   `sql:"user_type"`
	sql.AuditLog
}

type UserRepository

type UserRepository interface {
	CreateUser(userModel *UserModel, tx *pg.Tx) (*UserModel, error)
	UpdateUser(userModel *UserModel, tx *pg.Tx) (*UserModel, error)
	GetById(id int32) (*UserModel, error)
	GetByIdIncludeDeleted(id int32) (*UserModel, error)
	GetAllExcludingApiTokenUser() ([]UserModel, error)
	FetchActiveUserByEmail(email string) (bean.UserInfo, error)
	FetchUserDetailByEmail(email string) (bean.UserInfo, error)
	GetByIds(ids []int32) ([]UserModel, error)
	GetConnection() (dbConnection *pg.DB)
	FetchUserMatchesByEmailId(email string) ([]UserModel, error)
	FetchActiveOrDeletedUserByEmail(email string) (*UserModel, error)
}

type UserRepositoryImpl

type UserRepositoryImpl struct {
	Logger *zap.SugaredLogger
	// contains filtered or unexported fields
}

func NewUserRepositoryImpl

func NewUserRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger) *UserRepositoryImpl

func (UserRepositoryImpl) CreateUser

func (impl UserRepositoryImpl) CreateUser(userModel *UserModel, tx *pg.Tx) (*UserModel, error)

func (UserRepositoryImpl) FetchActiveOrDeletedUserByEmail

func (impl UserRepositoryImpl) FetchActiveOrDeletedUserByEmail(email string) (*UserModel, error)

func (UserRepositoryImpl) FetchActiveUserByEmail

func (impl UserRepositoryImpl) FetchActiveUserByEmail(email string) (bean.UserInfo, error)

func (UserRepositoryImpl) FetchUserDetailByEmail

func (impl UserRepositoryImpl) FetchUserDetailByEmail(email string) (bean.UserInfo, error)

func (UserRepositoryImpl) FetchUserMatchesByEmailId

func (impl UserRepositoryImpl) FetchUserMatchesByEmailId(email string) ([]UserModel, error)

func (UserRepositoryImpl) GetAllExcludingApiTokenUser

func (impl UserRepositoryImpl) GetAllExcludingApiTokenUser() ([]UserModel, error)

func (UserRepositoryImpl) GetById

func (impl UserRepositoryImpl) GetById(id int32) (*UserModel, error)

func (UserRepositoryImpl) GetByIdIncludeDeleted

func (impl UserRepositoryImpl) GetByIdIncludeDeleted(id int32) (*UserModel, error)

func (UserRepositoryImpl) GetByIds

func (impl UserRepositoryImpl) GetByIds(ids []int32) ([]UserModel, error)

func (*UserRepositoryImpl) GetConnection

func (impl *UserRepositoryImpl) GetConnection() (dbConnection *pg.DB)

func (UserRepositoryImpl) UpdateUser

func (impl UserRepositoryImpl) UpdateUser(userModel *UserModel, tx *pg.Tx) (*UserModel, error)

type UserRoleModel

type UserRoleModel struct {
	TableName struct{} `sql:"user_roles"`
	Id        int      `sql:"id,pk"`
	UserId    int32    `sql:"user_id,notnull"`
	RoleId    int      `sql:"role_id,notnull"`
	User      UserModel
	sql.AuditLog
}

Jump to

Keyboard shortcuts

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