user

package
v0.6.23-rc.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: Apache-2.0 Imports: 32 Imported by: 42

Documentation

Index

Constants

View Source
const (
	AllEnvironment string = ""
	AllNamespace   string = ""
	AllGroup       string = ""
	AllKind        string = ""
	AllResource    string = ""
)
View Source
const (
	ConcurrentRequestLockError   = "there is an ongoing request for this user, please try after some time"
	ConcurrentRequestUnlockError = "cannot block request that is not in process"
)

Variables

View Source
var (
	CookieExpirationTime int
	JwtExpirationTime    int
)
View Source
var Claims struct {
	Email    string   `json:"email"`
	Verified bool     `json:"email_verified"`
	Groups   []string `json:"groups"`
	Token    string   `json:"token"`
	Roles    []string `json:"roles"`
	jwt.StandardClaims
}

Functions

func WhitelistChecker added in v0.3.8

func WhitelistChecker(url string) bool

Types

type CheckResponse added in v0.4.2

type CheckResponse struct {
	Enabled bool     `json:"enabled"`
	Roles   []string `json:"roles"`
}

type DexConfig

type DexConfig struct {
	RedirectURL          string `env:"DEX_RURL" envDefault:"http://127.0.0.1:8080/callback"`
	ClientID             string `env:"DEX_CID" envDefault:"example-app"`
	ClientSecret         string `env:"DEX_SECRET" `
	DexURL               string `env:"DEX_URL" `
	DexJwtKey            string `env:"DEX_JWTKEY" `
	CStoreKey            string `env:"DEX_CSTOREKEY"`
	CookieExpirationTime int    `env:"CExpirationTime" envDefault:"600"`
	JwtExpirationTime    int    `env:"JwtExpirationTime" envDefault:"120"`
}

func GetConfig

func GetConfig() (*DexConfig, error)

type RbacRoleService added in v0.6.17

type RbacRoleService interface {
	GetAllDefaultRoles() ([]*bean.RbacRoleDto, error)
}

type RbacRoleServiceImpl added in v0.6.17

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

func NewRbacRoleServiceImpl added in v0.6.17

func NewRbacRoleServiceImpl(logger *zap.SugaredLogger,
	rbacRoleDataRepository repository.RbacRoleDataRepository) *RbacRoleServiceImpl

func (*RbacRoleServiceImpl) GetAllDefaultRoles added in v0.6.17

func (impl *RbacRoleServiceImpl) GetAllDefaultRoles() ([]*bean.RbacRoleDto, error)

type RoleGroupService

type RoleGroupService interface {
	CreateRoleGroup(request *bean.RoleGroup) (*bean.RoleGroup, error)
	UpdateRoleGroup(request *bean.RoleGroup, token string, managerAuth func(resource, token string, object string) bool) (*bean.RoleGroup, error)
	FetchDetailedRoleGroups() ([]*bean.RoleGroup, error)
	FetchRoleGroupsById(id int32) (*bean.RoleGroup, error)
	FetchRoleGroups() ([]*bean.RoleGroup, error)
	FetchRoleGroupsByName(name string) ([]*bean.RoleGroup, error)
	DeleteRoleGroup(model *bean.RoleGroup) (bool, error)
	FetchRolesForGroups(groupNames []string) ([]*bean.RoleFilter, error)
}

type RoleGroupServiceImpl

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

func NewRoleGroupServiceImpl

func NewRoleGroupServiceImpl(userAuthRepository repository2.UserAuthRepository,
	logger *zap.SugaredLogger, userRepository repository2.UserRepository,
	roleGroupRepository repository2.RoleGroupRepository, userCommonService UserCommonService) *RoleGroupServiceImpl

func (RoleGroupServiceImpl) CreateOrUpdateRoleGroupForClusterEntity added in v0.6.11

func (impl RoleGroupServiceImpl) CreateOrUpdateRoleGroupForClusterEntity(roleFilter bean.RoleFilter, userId int32, model *repository2.RoleGroup, existingRoles map[int]*repository2.RoleGroupRoleMapping, token string, managerAuth func(resource string, token string, object string) bool, tx *pg.Tx, capacity int) ([]casbin2.Policy, error)

func (RoleGroupServiceImpl) CreateRoleGroup

func (impl RoleGroupServiceImpl) CreateRoleGroup(request *bean.RoleGroup) (*bean.RoleGroup, error)

func (RoleGroupServiceImpl) DeleteRoleGroup

func (impl RoleGroupServiceImpl) DeleteRoleGroup(bean *bean.RoleGroup) (bool, error)

func (RoleGroupServiceImpl) FetchDetailedRoleGroups added in v0.5.3

func (impl RoleGroupServiceImpl) FetchDetailedRoleGroups() ([]*bean.RoleGroup, error)

func (RoleGroupServiceImpl) FetchRoleGroups

func (impl RoleGroupServiceImpl) FetchRoleGroups() ([]*bean.RoleGroup, error)

func (RoleGroupServiceImpl) FetchRoleGroupsById

func (impl RoleGroupServiceImpl) FetchRoleGroupsById(id int32) (*bean.RoleGroup, error)

func (RoleGroupServiceImpl) FetchRoleGroupsByName

func (impl RoleGroupServiceImpl) FetchRoleGroupsByName(name string) ([]*bean.RoleGroup, error)

func (RoleGroupServiceImpl) FetchRolesForGroups added in v0.2.9

func (impl RoleGroupServiceImpl) FetchRolesForGroups(groupNames []string) ([]*bean.RoleFilter, error)

func (RoleGroupServiceImpl) UpdateRoleGroup

func (impl RoleGroupServiceImpl) UpdateRoleGroup(request *bean.RoleGroup, token string, managerAuth func(resource, token string, object string) bool) (*bean.RoleGroup, error)

type SelfRegistrationRolesService added in v0.4.2

type SelfRegistrationRolesService interface {
	Check() (CheckResponse, error)
	SelfRegister(emailId string) (*bean.UserInfo, error)
	CheckAndCreateUserIfConfigured(emailId string) bool
}

type SelfRegistrationRolesServiceImpl added in v0.4.2

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

func NewSelfRegistrationRolesServiceImpl added in v0.4.2

func NewSelfRegistrationRolesServiceImpl(logger *zap.SugaredLogger,
	selfRegistrationRolesRepository repository.SelfRegistrationRolesRepository, userService UserService) *SelfRegistrationRolesServiceImpl

func (*SelfRegistrationRolesServiceImpl) Check added in v0.4.2

func (*SelfRegistrationRolesServiceImpl) CheckAndCreateUserIfConfigured added in v0.4.24

func (impl *SelfRegistrationRolesServiceImpl) CheckAndCreateUserIfConfigured(emailId string) bool

func (*SelfRegistrationRolesServiceImpl) GetAll added in v0.4.2

func (impl *SelfRegistrationRolesServiceImpl) GetAll() ([]string, error)

func (*SelfRegistrationRolesServiceImpl) SelfRegister added in v0.4.2

func (impl *SelfRegistrationRolesServiceImpl) SelfRegister(emailId string) (*bean.UserInfo, error)

type User

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

type UserAudit added in v0.4.11

type UserAudit struct {
	UserId    int32
	ClientIp  string
	CreatedOn time.Time
	UpdatedOn time.Time
}

type UserAuditService added in v0.4.11

type UserAuditService interface {
	Save(userAudit *UserAudit) error
	GetLatestByUserId(userId int32) (*UserAudit, error)
	GetLatestUser() (*UserAudit, error)
	Update(userAudit *UserAudit) error
}

type UserAuditServiceImpl added in v0.4.11

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

func NewUserAuditServiceImpl added in v0.4.11

func NewUserAuditServiceImpl(logger *zap.SugaredLogger, userAuditRepository repository2.UserAuditRepository) *UserAuditServiceImpl

func (UserAuditServiceImpl) GetLatestByUserId added in v0.4.11

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

func (UserAuditServiceImpl) GetLatestUser added in v0.6.4

func (impl UserAuditServiceImpl) GetLatestUser() (*UserAudit, error)

func (UserAuditServiceImpl) Save added in v0.4.11

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

func (UserAuditServiceImpl) Update added in v0.6.4

func (impl UserAuditServiceImpl) Update(userAudit *UserAudit) error

type UserAuthService

type UserAuthService interface {
	HandleLoginWithClientIp(ctx context.Context, username, password, clientIp string) (string, error)
	HandleLogin(username string, password string) (string, error)
	HandleDexCallback(w http.ResponseWriter, r *http.Request)
	HandleRefresh(w http.ResponseWriter, r *http.Request)

	CreateRole(roleData *bean.RoleData) (bool, error)
	AuthVerification(r *http.Request) (bool, error)
	DeleteRoles(entityType string, entityName string, tx *pg.Tx, envIdentifier string) error
}

type UserAuthServiceImpl

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

func NewUserAuthServiceImpl

func NewUserAuthServiceImpl(userAuthRepository repository2.UserAuthRepository, sessionManager *middleware.SessionManager,
	client session2.ServiceClient, logger *zap.SugaredLogger, userRepository repository2.UserRepository,
	roleGroupRepository repository2.RoleGroupRepository, userService UserService) *UserAuthServiceImpl

func (UserAuthServiceImpl) AuthVerification

func (impl UserAuthServiceImpl) AuthVerification(r *http.Request) (bool, error)

func (UserAuthServiceImpl) CreateRole

func (impl UserAuthServiceImpl) CreateRole(roleData *bean.RoleData) (bool, error)

func (UserAuthServiceImpl) DeleteRoles added in v0.3.15

func (impl UserAuthServiceImpl) DeleteRoles(entityType string, entityName string, tx *pg.Tx, envIdentifier string) (err error)

func (UserAuthServiceImpl) HandleDexCallback

func (impl UserAuthServiceImpl) HandleDexCallback(w http.ResponseWriter, r *http.Request)

func (UserAuthServiceImpl) HandleLogin

func (impl UserAuthServiceImpl) HandleLogin(username string, password string) (string, error)

func (UserAuthServiceImpl) HandleLoginWithClientIp added in v0.6.4

func (impl UserAuthServiceImpl) HandleLoginWithClientIp(ctx context.Context, username, password, clientIp string) (string, error)

func (UserAuthServiceImpl) HandleRefresh

func (impl UserAuthServiceImpl) HandleRefresh(w http.ResponseWriter, r *http.Request)

type UserCommonService added in v0.3.14

type UserCommonService interface {
	CreateDefaultPoliciesForAllTypes(team, entityName, env, entity, cluster, namespace, group, kind, resource, actionType, accessType string, userId int32) (bool, error, []casbin.Policy)
	RemoveRolesAndReturnEliminatedPolicies(userInfo *bean.UserInfo, existingRoleIds map[int]repository2.UserRoleModel, eliminatedRoleIds map[int]*repository2.UserRoleModel, tx *pg.Tx, token string, managerAuth func(resource, token, object string) bool) ([]casbin.Policy, error)
	RemoveRolesAndReturnEliminatedPoliciesForGroups(request *bean.RoleGroup, existingRoles map[int]*repository2.RoleGroupRoleMapping, eliminatedRoles map[int]*repository2.RoleGroupRoleMapping, tx *pg.Tx, token string, managerAuth func(resource string, token string, object string) bool) ([]casbin.Policy, error)
	CheckRbacForClusterEntity(cluster, namespace, group, kind, resource, token string, managerAuth func(resource, token, object string) bool) bool
	ReplacePlaceHolderForEmptyEntriesInRoleFilter(roleFilter bean.RoleFilter) bean.RoleFilter
	RemovePlaceHolderInRoleFilterField(roleFilterField string) string
	GetCapacityForRoleFilter(roleFilters []bean.RoleFilter) (int, map[int]int)
}

type UserCommonServiceImpl added in v0.3.14

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

func NewUserCommonServiceImpl added in v0.3.14

func NewUserCommonServiceImpl(userAuthRepository repository2.UserAuthRepository,
	logger *zap.SugaredLogger,
	userRepository repository2.UserRepository,
	userGroupRepository repository2.RoleGroupRepository,
	sessionManager2 *middleware.SessionManager,
	defaultRbacDataCacheFactory repository2.RbacDataCacheFactory) *UserCommonServiceImpl

func (UserCommonServiceImpl) CheckRbacForClusterEntity added in v0.6.11

func (impl UserCommonServiceImpl) CheckRbacForClusterEntity(cluster, namespace, group, kind, resource, token string, managerAuth func(resource, token, object string) bool) bool

func (UserCommonServiceImpl) CreateDefaultPoliciesForAllTypes added in v0.6.17

func (impl UserCommonServiceImpl) CreateDefaultPoliciesForAllTypes(team, entityName, env, entity, cluster, namespace, group, kind, resource, actionType, accessType string, userId int32) (bool, error, []casbin.Policy)

func (UserCommonServiceImpl) CreateDefaultPoliciesForAllTypesV2 added in v0.6.17

func (impl UserCommonServiceImpl) CreateDefaultPoliciesForAllTypesV2(team, entityName, env, entity, cluster, namespace, group, kind, resource, actionType, accessType string) (bool, error, []casbin.Policy)

func (UserCommonServiceImpl) GetCapacityForRoleFilter added in v0.6.16

func (impl UserCommonServiceImpl) GetCapacityForRoleFilter(roleFilters []bean.RoleFilter) (int, map[int]int)

func (UserCommonServiceImpl) RemovePlaceHolderInRoleFilterField added in v0.6.16

func (impl UserCommonServiceImpl) RemovePlaceHolderInRoleFilterField(roleFilterField string) string

func (UserCommonServiceImpl) RemoveRolesAndReturnEliminatedPolicies added in v0.3.14

func (impl UserCommonServiceImpl) RemoveRolesAndReturnEliminatedPolicies(userInfo *bean.UserInfo,
	existingRoleIds map[int]repository2.UserRoleModel, eliminatedRoleIds map[int]*repository2.UserRoleModel,
	tx *pg.Tx, token string, managerAuth func(resource, token, object string) bool) ([]casbin.Policy, error)

func (UserCommonServiceImpl) RemoveRolesAndReturnEliminatedPoliciesForGroups added in v0.3.14

func (impl UserCommonServiceImpl) RemoveRolesAndReturnEliminatedPoliciesForGroups(request *bean.RoleGroup, existingRoles map[int]*repository2.RoleGroupRoleMapping, eliminatedRoles map[int]*repository2.RoleGroupRoleMapping, tx *pg.Tx, token string, managerAuth func(resource string, token string, object string) bool) ([]casbin.Policy, error)

func (UserCommonServiceImpl) ReplacePlaceHolderForEmptyEntriesInRoleFilter added in v0.6.16

func (impl UserCommonServiceImpl) ReplacePlaceHolderForEmptyEntriesInRoleFilter(roleFilter bean.RoleFilter) bean.RoleFilter

type UserRbacConfig added in v0.6.17

type UserRbacConfig struct {
	UseRbacCreationV2 bool `env:"USE_RBAC_CREATION_V2" envDefault:"false"`
}

type UserService

type UserService interface {
	CreateUser(userInfo *bean.UserInfo, token string, managerAuth func(resource, token string, object string) bool) ([]*bean.UserInfo, error)
	SelfRegisterUserIfNotExists(userInfo *bean.UserInfo) ([]*bean.UserInfo, error)
	UpdateUser(userInfo *bean.UserInfo, token string, managerAuth func(resource, token string, object string) bool) (*bean.UserInfo, bool, bool, []string, error)
	GetById(id int32) (*bean.UserInfo, error)
	GetAll() ([]bean.UserInfo, error)
	GetAllDetailedUsers() ([]bean.UserInfo, error)
	GetEmailFromToken(token string) (string, error)
	GetLoggedInUser(r *http.Request) (int32, error)
	GetByIds(ids []int32) ([]bean.UserInfo, error)
	DeleteUser(userInfo *bean.UserInfo) (bool, error)
	CheckUserRoles(id int32) ([]string, error)
	SyncOrchestratorToCasbin() (bool, error)
	GetUserByToken(context context.Context, token string) (int32, string, error)
	IsSuperAdmin(userId int) (bool, error)
	GetByIdIncludeDeleted(id int32) (*bean.UserInfo, error)
	UserExists(emailId string) bool
	UpdateTriggerPolicyForTerminalAccess() (err error)
	GetRoleFiltersByGroupNames(groupNames []string) ([]bean.RoleFilter, error)
	SaveLoginAudit(emailId, clientIp string, id int32)
}

type UserServiceImpl

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

func NewUserServiceImpl

func NewUserServiceImpl(userAuthRepository repository2.UserAuthRepository,
	logger *zap.SugaredLogger,
	userRepository repository2.UserRepository,
	userGroupRepository repository2.RoleGroupRepository,
	sessionManager2 *middleware.SessionManager, userCommonService UserCommonService, userAuditService UserAuditService) *UserServiceImpl

func (*UserServiceImpl) CheckUserRoles

func (impl *UserServiceImpl) CheckUserRoles(id int32) ([]string, error)

func (*UserServiceImpl) CreateOrUpdateUserRolesForAllTypes added in v0.6.16

func (impl *UserServiceImpl) CreateOrUpdateUserRolesForAllTypes(roleFilter bean.RoleFilter, userId int32, model *repository2.UserModel, existingRoles map[int]repository2.UserRoleModel, token string, managerAuth func(resource string, token string, object string) bool, tx *pg.Tx, entity string, capacity int) ([]casbin2.Policy, bool, error)

func (*UserServiceImpl) CreateUser

func (impl *UserServiceImpl) CreateUser(userInfo *bean.UserInfo, token string, managerAuth func(resource, token string, object string) bool) ([]*bean.UserInfo, error)

func (*UserServiceImpl) DeleteUser

func (impl *UserServiceImpl) DeleteUser(bean *bean.UserInfo) (bool, error)

func (*UserServiceImpl) GetAll

func (impl *UserServiceImpl) GetAll() ([]bean.UserInfo, error)

GetAll excluding API token user

func (*UserServiceImpl) GetAllDetailedUsers added in v0.5.3

func (impl *UserServiceImpl) GetAllDetailedUsers() ([]bean.UserInfo, error)

func (*UserServiceImpl) GetById

func (impl *UserServiceImpl) GetById(id int32) (*bean.UserInfo, error)

func (*UserServiceImpl) GetByIdIncludeDeleted added in v0.2.32

func (impl *UserServiceImpl) GetByIdIncludeDeleted(id int32) (*bean.UserInfo, error)

func (*UserServiceImpl) GetByIds

func (impl *UserServiceImpl) GetByIds(ids []int32) ([]bean.UserInfo, error)

func (*UserServiceImpl) GetEmailFromToken added in v0.4.9

func (impl *UserServiceImpl) GetEmailFromToken(token string) (string, error)

func (*UserServiceImpl) GetLoggedInUser

func (impl *UserServiceImpl) GetLoggedInUser(r *http.Request) (int32, error)

func (*UserServiceImpl) GetRoleFiltersByGroupNames added in v0.6.0

func (impl *UserServiceImpl) GetRoleFiltersByGroupNames(groupNames []string) ([]bean.RoleFilter, error)

func (*UserServiceImpl) GetUserByEmail

func (impl *UserServiceImpl) GetUserByEmail(emailId string) (*bean.UserInfo, error)

func (*UserServiceImpl) GetUserByToken

func (impl *UserServiceImpl) GetUserByToken(context context.Context, token string) (int32, string, error)

func (*UserServiceImpl) IsSuperAdmin

func (impl *UserServiceImpl) IsSuperAdmin(userId int) (bool, error)

func (*UserServiceImpl) SaveLoginAudit added in v0.6.4

func (impl *UserServiceImpl) SaveLoginAudit(emailId, clientIp string, id int32)

func (*UserServiceImpl) SelfRegisterUserIfNotExists added in v0.4.2

func (impl *UserServiceImpl) SelfRegisterUserIfNotExists(userInfo *bean.UserInfo) ([]*bean.UserInfo, error)

func (*UserServiceImpl) SyncOrchestratorToCasbin

func (impl *UserServiceImpl) SyncOrchestratorToCasbin() (bool, error)

func (*UserServiceImpl) UpdateTriggerPolicyForTerminalAccess added in v0.3.15

func (impl *UserServiceImpl) UpdateTriggerPolicyForTerminalAccess() (err error)

func (*UserServiceImpl) UpdateUser

func (impl *UserServiceImpl) UpdateUser(userInfo *bean.UserInfo, token string, managerAuth func(resource, token string, object string) bool) (*bean.UserInfo, bool, bool, []string, error)

func (*UserServiceImpl) UserExists added in v0.3.8

func (impl *UserServiceImpl) UserExists(emailId string) bool

type WebhookToken

type WebhookToken struct {
	WebhookToken string `env:"WEBHOOK_TOKEN" envDefault:""`
}

func GetWebhookToken

func GetWebhookToken() (*WebhookToken, error)

Directories

Path Synopsis
Package mock_user is a generated GoMock package.
Package mock_user is a generated GoMock package.
casbin
Package mock_casbin is a generated GoMock package.
Package mock_casbin is a generated GoMock package.

Jump to

Keyboard shortcuts

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