service

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 67 Imported by: 1

Documentation

Index

Constants

View Source
const (
	OrgRelayAuditPermission     = "org.relayAudit.read"
	ProjectRelayAuditPermission = "project.relayAudit.read"
	ProjectAuditLogPermission   = "project.auditLog.read"
)

auditlogs permissions

View Source
const (
	AuditActionCreate   = "create"
	AuditActionDelete   = "delete"
	AuditActionUpdate   = "update"
	AuditActionDownload = "download"
)

Variables

Functions

func CreateApiKeyAuditEvent

func CreateApiKeyAuditEvent(ctx context.Context, al *zap.Logger, action string, id string)

func CreateClusterAuditEvent

func CreateClusterAuditEvent(ctx context.Context, al *zap.Logger, action string, name string, id uuid.UUID, project string)

func CreateGroupAuditEvent

func CreateGroupAuditEvent(ctx context.Context, al *zap.Logger, db bun.IDB, action string, name string, id uuid.UUID, usersBefore, usersAfter, rolesBefore, rolesAfter []uuid.UUID)

func CreateIdpAuditEvent

func CreateIdpAuditEvent(ctx context.Context, al *zap.Logger, action string, name string, id uuid.UUID)

func CreateLocationAuditEvent

func CreateLocationAuditEvent(ctx context.Context, al *zap.Logger, action string, name string, id uuid.UUID)

TODO: figure out how this is to be added

func CreateOidcAuditEvent

func CreateOidcAuditEvent(ctx context.Context, al *zap.Logger, action string, name string, id uuid.UUID)

func CreateOrganizationAuditEvent

func CreateOrganizationAuditEvent(ctx context.Context, al *zap.Logger, action string, name string, id uuid.UUID, settingsBefore, settingsAfter *systemv3.OrganizationSettings)

func CreatePartnerAuditEvent

func CreatePartnerAuditEvent(ctx context.Context, al *zap.Logger, action string, name string, id uuid.UUID)

func CreateProjectAuditEvent

func CreateProjectAuditEvent(ctx context.Context, al *zap.Logger, action string, name string, id uuid.UUID)

func CreateRoleAuditEvent

func CreateRoleAuditEvent(ctx context.Context, al *zap.Logger, action string, name string, id uuid.UUID, permissions []string)

func CreateUserAuditEvent

func CreateUserAuditEvent(ctx context.Context, al *zap.Logger, db bun.IDB, action string, name string, id uuid.UUID, rolesBefore, rolesAfter, groupsBefore, groupsAfter []uuid.UUID)

func CreateUserLoginAuditEvent added in v0.1.9

func CreateUserLoginAuditEvent(ctx context.Context, al *zap.Logger, action string, name string)

func DeleteRelayAgent added in v0.1.9

func DeleteRelayAgent(ctx context.Context, kubeConfig []byte, namespace string) bool

func DownloadCliConfigAuditEvent added in v0.1.3

func DownloadCliConfigAuditEvent(ctx context.Context, al *zap.Logger, action string, user string)

func DownloadKubeconfigAuditEvent added in v0.1.3

func DownloadKubeconfigAuditEvent(ctx context.Context, al *zap.Logger, user string)

func GetSessionDataFromContext

func GetSessionDataFromContext(ctx context.Context) (*commonv3.SessionData, bool)

func IsInternalRequest

func IsInternalRequest(ctx context.Context) bool

func RevokeKubeconfigAuditEvent

func RevokeKubeconfigAuditEvent(ctx context.Context, al *zap.Logger, user string)

func ValidateUserAuditReadRequest added in v0.2.5

func ValidateUserAuditReadRequest(ctx context.Context, projects []string, db *bun.DB, isRelayAudit bool) error

Types

type AccountPermissionService

type AccountPermissionService interface {
	GetAccountPermissions(ctx context.Context, accountID string, orgID, partnerID string) ([]sentry.AccountPermission, error)
	IsPartnerSuperAdmin(ctx context.Context, accountID, partnerID string) (isPartnerAdmin, isSuperAdmin bool, err error)
	GetAccountProjectsByPermission(ctx context.Context, accountID, orgID, partnerID string, permission string) ([]sentry.AccountPermission, error)
	GetAccountPermissionsByProjectIDPermissions(ctx context.Context, accountID, orgID, partnerID string, projects, permissions []string) ([]sentry.AccountPermission, error)
	GetAcccountsWithApprovalPermission(ctx context.Context, orgID, partnerID string) ([]string, error)
	GetSSOAcccountsWithApprovalPermission(ctx context.Context, orgID, partnerID string) ([]string, error)
	IsOrgAdmin(ctx context.Context, accountID, partnerID string) (isOrgAdmin bool, err error)
	GetAccount(ctx context.Context, accountID string) (*models.Account, error)
	GetAccountGroups(ctx context.Context, accountID string) ([]string, error)
	IsAccountActive(ctx context.Context, accountID, orgID string) (bool, error)
	IsSSOAccount(ctx context.Context, accountID string) (bool, error)
}

AccountPermissionService is the interface for account permission operations

func NewAccountPermissionService

func NewAccountPermissionService(db *bun.DB) AccountPermissionService

NewKubeconfigRevocation return new kubeconfig revocation service

type ApUpdate

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

type ApiKeyService

type ApiKeyService interface {
	// create api key
	Create(ctx context.Context, req *rpcv3.ApiKeyRequest) (*models.ApiKey, error)
	// get by user
	Get(ctx context.Context, req *rpcv3.ApiKeyRequest) (*models.ApiKey, error)
	// get by key
	GetByKey(ctx context.Context, req *rpcv3.ApiKeyRequest) (*models.ApiKey, error)
	// delete api key
	Delete(ctx context.Context, req *rpcv3.ApiKeyRequest) (*rpcv3.UserDeleteApiKeysResponse, error)
	// list api keys
	List(ctx context.Context, req *rpcv3.ApiKeyRequest) (*rpcv3.UserListApiKeysResponse, error)
}

ApiKeyService is the interface for api key operations

func NewApiKeyService

func NewApiKeyService(db *bun.DB, al *zap.Logger) ApiKeyService

NewApiKeyService return new api key service

type AuditLogService

type AuditLogService interface {
	GetAuditLog(ctx context.Context, req *v1.GetAuditLogSearchRequest) (res *v1.GetAuditLogSearchResponse, err error)
	GetAuditLogByProjects(ctx context.Context, req *v1.GetAuditLogSearchRequest) (res *v1.GetAuditLogSearchResponse, err error)
}

func NewAuditLogDatabaseService added in v0.1.8

func NewAuditLogDatabaseService(db *bun.DB, tag string) (AuditLogService, error)

func NewAuditLogElasticSearchService added in v0.1.8

func NewAuditLogElasticSearchService(url string, auditPattern string, logPrefix string, db *bun.DB) (AuditLogService, error)

type AuthzService

func NewAuthzService

func NewAuthzService(db *bun.DB, en *casbin.CachedEnforcer) AuthzService

type BootstrapService

type BootstrapService interface {
	// bootstrap infra methods
	PatchBootstrapInfra(ctx context.Context, infra *sentry.BootstrapInfra) error
	GetBootstrapInfra(ctx context.Context, name string) (*sentry.BootstrapInfra, error)
	// bootstrap template methods
	PatchBootstrapAgentTemplate(ctx context.Context, template *sentry.BootstrapAgentTemplate) error
	GetBootstrapAgentTemplate(ctx context.Context, name string) (*sentry.BootstrapAgentTemplate, error)
	GetBootstrapAgentTemplateForToken(ctx context.Context, token string) (*sentry.BootstrapAgentTemplate, error)
	GetBootstrapAgentTemplateForHost(ctx context.Context, host string) (*sentry.BootstrapAgentTemplate, error)
	SelectBootstrapAgentTemplates(ctx context.Context, opts ...query.Option) (*sentry.BootstrapAgentTemplateList, error)
	// bootstrap agent methods
	CreateBootstrapAgent(ctx context.Context, agent *sentry.BootstrapAgent) error
	GetBootstrapAgent(ctx context.Context, templateRef string, opts ...query.Option) (*sentry.BootstrapAgent, error)
	GetBootstrapAgents(ctx context.Context, templateRef string, opts ...query.Option) (*sentry.BootstrapAgentList, error)
	GetBootstrapAgentForToken(ctx context.Context, token string) (*sentry.BootstrapAgent, error)
	GetBootstrapAgentCountForClusterID(ctx context.Context, clusterID string, orgID string) (int, error)
	GetBootstrapAgentForClusterID(ctx context.Context, clusterID string, orgID string) (*sentry.BootstrapAgent, error)
	SelectBootstrapAgents(ctx context.Context, templateRef string, opts ...query.Option) (*sentry.BootstrapAgentList, error)
	RegisterBootstrapAgent(ctx context.Context, token, ip, fingerprint string) error
	DeleteBootstrapAgent(ctx context.Context, templateRef string, opts ...query.Option) error
	PatchBootstrapAgent(ctx context.Context, ba *sentry.BootstrapAgent, templateRef string, opts ...query.Option) error
}

BootstrapService is the interface for bootstrap operations

func NewBootstrapService

func NewBootstrapService(db *bun.DB) BootstrapService

NewBootstrapService return new bootstrap service

type ClusterService

type ClusterService interface {
	// create Cluster
	Create(ctx context.Context, cluster *infrav3.Cluster) (*infrav3.Cluster, error)
	// get cluster
	Select(ctx context.Context, cluster *infrav3.Cluster, isExtended bool) (*infrav3.Cluster, error)
	// get cluster
	Get(ctx context.Context, opts ...query.Option) (*infrav3.Cluster, error)
	// create or update cluster
	Update(ctx context.Context, cluster *infrav3.Cluster) (*infrav3.Cluster, error)
	// delete cluster
	Delete(ctx context.Context, cluster *infrav3.Cluster) error
	// list cluster
	List(ctx context.Context, opts ...query.Option) (*infrav3.ClusterList, error)
	//update cluster status
	UpdateClusterConditionStatus(ctx context.Context, current *infrav3.Cluster) error
	// update cluster annotations
	UpdateClusterAnnotations(ctx context.Context, cluster *infrav3.Cluster) error
	//listen clusters
	ListenClusters(ctx context.Context, mChan chan<- commonv3.Metadata)
	//Get cluster projects
	GetClusterProjects(ctx context.Context, cluster *infrav3.Cluster) ([]models.ProjectCluster, error)
	//Validate and update cluster status
	UpdateStatus(ctx context.Context, current *infrav3.Cluster, opts ...query.Option) error
	// Create bootstrap agent for cluster
	CreateBootstrapAgentForCluster(ctx context.Context, cluster *infrav3.Cluster) error
	// Get relay config for cluster
	GetRelaysConfigForCluster(ctx context.Context, cluster *infrav3.Cluster) ([]common.Relay, error)
	// Update projects for bootstrap agents for cluster
	UpdateProjectsForBootstrapAgentForCluster(ctx context.Context, cluster *infrav3.Cluster) error
	//Add event handlers
	AddEventHandler(evh event.Handler)
}

func NewClusterService

func NewClusterService(db *bun.DB, data *common.DownloadData, bs BootstrapService, al *zap.Logger) ClusterService

NewClusterService return new cluster service

type ElasticSearchQuery

type ElasticSearchQuery interface {
	Handle(bytes.Buffer) (map[string]interface{}, error)
}

func NewElasticSearchQuery

func NewElasticSearchQuery(url string, indexPattern string, logPrefix string) (ElasticSearchQuery, error)

type GroupPermissionService

type GroupPermissionService interface {
	GetGroupPermissions(ctx context.Context, groupNames []string, orgID, partnerID string) ([]sentry.GroupPermission, error)
	GetGroupProjectsByPermission(ctx context.Context, groupNames []string, orgID, partnerID string, permission string) ([]sentry.GroupPermission, error)
	GetGroupPermissionsByProjectIDPermissions(ctx context.Context, groupNames []string, orgID, partnerID string, projects []string, permissions []string) ([]sentry.GroupPermission, error)
	GetProjectByGroup(ctx context.Context, groupNames []string, orgID, partnerID string) ([]sentry.GroupPermission, error)
}

GroupPermissionService is the interface for group permission operations

func NewGroupPermissionService

func NewGroupPermissionService(db *bun.DB) GroupPermissionService

NewKubeconfigRevocation return new kubeconfig revocation service

type GroupService

type GroupService interface {
	// create group
	Create(context.Context, *userv3.Group) (*userv3.Group, error)
	// get group by id
	GetByID(context.Context, *userv3.Group) (*userv3.Group, error)
	// get group by name
	GetByName(context.Context, *userv3.Group) (*userv3.Group, error)
	// create or update group
	Update(context.Context, *userv3.Group) (*userv3.Group, error)
	// delete group
	Delete(context.Context, *userv3.Group) (*userv3.Group, error)
	// list groups
	List(context.Context, ...query.Option) (*userv3.GroupList, error)
}

GroupService is the interface for group operations

func NewGroupService

func NewGroupService(db *bun.DB, azc AuthzService, al *zap.Logger) GroupService

NewGroupService return new group service

type IdpService

func NewIdpService

func NewIdpService(db *bun.DB, hostUrl string, al *zap.Logger) IdpService

type KubeconfigRevocationService

type KubeconfigRevocationService interface {
	Get(ctx context.Context, orgID string, accountID string, isSSOUser bool) (*sentry.KubeconfigRevocation, error)
	Patch(ctx context.Context, kr *sentry.KubeconfigRevocation) error
}

KubeconfigRevocation is the interface for bootstrap operations

func NewKubeconfigRevocationService

func NewKubeconfigRevocationService(db *bun.DB, al *zap.Logger) KubeconfigRevocationService

NewKubeconfigRevocation return new kubeconfig revocation service

type KubeconfigSettingService

type KubeconfigSettingService interface {
	Get(ctx context.Context, orgID string, accountID string, isSSO bool) (*sentry.KubeconfigSetting, error)
	Patch(ctx context.Context, ks *sentry.KubeconfigSetting) error
}

KubeconfigSettingService is the interface for kube config setting operations

func NewKubeconfigSettingService

func NewKubeconfigSettingService(db *bun.DB) KubeconfigSettingService

NewKubeconfigSettingService return new kubeconfig setting service

type KubectlClusterSettingsService

type KubectlClusterSettingsService interface {
	Get(ctx context.Context, orgID string, clusterID string) (*sentry.KubectlClusterSettings, error)
	Patch(ctx context.Context, kc *sentry.KubectlClusterSettings) error
}

KubectlClusterSettingsService is the interface for kubectl cluster setting operations

func NewkubectlClusterSettingsService

func NewkubectlClusterSettingsService(db *bun.DB) KubectlClusterSettingsService

NewKubectlClusterSettingsService return new kubectl cluster setting service

type MetroService

type MetroService interface {
	// create metro
	Create(ctx context.Context, metro *infrav3.Location) (*infrav3.Location, error)
	// get metro by id
	GetById(ctx context.Context, id uuid.UUID) (*infrav3.Location, error)
	// get metro by name
	GetByName(ctx context.Context, name string) (*infrav3.Location, error)
	// get metro id by name
	GetIDByName(ctx context.Context, name string) (uuid.UUID, error)
	// create or update metro
	Update(ctx context.Context, metro *infrav3.Location) (*infrav3.Location, error)
	// delete metro
	Delete(ctx context.Context, metro *infrav3.Location) (*infrav3.Location, error)
	// list metro
	List(ctx context.Context, partner string) (*infrav3.LocationList, error)
}

MetroService is the interface for metro operations

func NewMetroService

func NewMetroService(db *bun.DB) MetroService

NewProjectService return new project service

type NamespaceService

type NamespaceService interface {
	// GetProjectNamespaces
	GetProjectNamespaces(ctx context.Context, projectID uuid.UUID) ([]string, error)
	GetAccountProjectNamespaces(ctx context.Context, projectID uuid.UUID, accountID uuid.UUID) ([]string, error)
	GetGroupProjectNamespaces(ctx context.Context, projectID uuid.UUID, accountID uuid.UUID) ([]string, error)
}

NamespaceService is the interface for namespace operations

func NewNamespaceService

func NewNamespaceService(db *bun.DB) NamespaceService

NewNamespaceService return new namespace service

type OrganizationService

type OrganizationService interface {
	// create organization
	Create(ctx context.Context, organization *systemv3.Organization) (*systemv3.Organization, error)
	// get organization by id
	GetByID(ctx context.Context, id string) (*systemv3.Organization, error)
	// get organization by id
	GetByName(ctx context.Context, name string) (*systemv3.Organization, error)
	// create or update organization
	Update(ctx context.Context, organization *systemv3.Organization) (*systemv3.Organization, error)
	// delete organization
	Delete(ctx context.Context, organization *systemv3.Organization) (*systemv3.Organization, error)
	// list organization
	List(ctx context.Context, organization *systemv3.Organization) (*systemv3.OrganizationList, error)
}

OrganizationService is the interface for organization operations

func NewOrganizationService

func NewOrganizationService(db *bun.DB, al *zap.Logger) OrganizationService

NewOrganizationService return new organization service

type PartnerService

type PartnerService interface {
	// create partner
	Create(ctx context.Context, partner *systemv3.Partner) (*systemv3.Partner, error)
	// get partner by id
	GetByID(ctx context.Context, partnerId string) (*systemv3.Partner, error)
	// get partner by id
	GetByName(ctx context.Context, name string) (*systemv3.Partner, error)
	// create or update partner
	Update(ctx context.Context, partner *systemv3.Partner) (*systemv3.Partner, error)
	// delete partner
	Delete(ctx context.Context, partner *systemv3.Partner) (*systemv3.Partner, error)
	// list partner
	GetOnlyPartner(ctx context.Context) (*systemv3.Partner, error)
}

PartnerService is the interface for partner operations

func NewPartnerService

func NewPartnerService(db *bun.DB, al *zap.Logger) PartnerService

NewPartnerService return new partner service

type ProjectService

type ProjectService interface {
	// create project
	Create(ctx context.Context, project *systemv3.Project) (*systemv3.Project, error)
	// get project by id
	GetByID(ctx context.Context, id string) (*systemv3.Project, error)
	// get project by name
	GetByName(ctx context.Context, name string) (*systemv3.Project, error)
	// create or update project
	Update(ctx context.Context, project *systemv3.Project) (*systemv3.Project, error)
	// delete project
	Delete(ctx context.Context, project *systemv3.Project) (*systemv3.Project, error)
	// list projects
	List(ctx context.Context, project *systemv3.Project) (*systemv3.ProjectList, error)
}

ProjectService is the interface for project operations

func NewProjectService

func NewProjectService(db *bun.DB, azc AuthzService, al *zap.Logger, dev bool) ProjectService

NewProjectService return new project service

type RelayAuditService

type RelayAuditService interface {
	GetRelayAudit(ctx context.Context, req *v1.RelayAuditRequest) (res *v1.RelayAuditResponse, err error)
	GetRelayAuditByProjects(ctx context.Context, req *v1.RelayAuditRequest) (res *v1.RelayAuditResponse, err error)
}

func NewRelayAuditDatabaseService added in v0.1.8

func NewRelayAuditDatabaseService(db *bun.DB, tag string) (RelayAuditService, error)

func NewRelayAuditElasticSearchService added in v0.1.8

func NewRelayAuditElasticSearchService(url string, auditPattern string, logPrefix string, db *bun.DB) (RelayAuditService, error)

type RoleService

type RoleService interface {
	// create role
	Create(context.Context, *rolev3.Role) (*rolev3.Role, error)
	// get role by id
	GetByID(context.Context, *rolev3.Role) (*rolev3.Role, error)
	// get role by name
	GetByName(context.Context, *rolev3.Role) (*rolev3.Role, error)
	// create or update role
	Update(context.Context, *rolev3.Role) (*rolev3.Role, error)
	// delete role
	Delete(context.Context, *rolev3.Role) (*rolev3.Role, error)
	// list roles
	List(context.Context, *rolev3.Role) (*rolev3.RoleList, error)
}

RoleService is the interface for role operations

func NewRoleService

func NewRoleService(db *bun.DB, azc AuthzService, al *zap.Logger) RoleService

NewRoleService return new role service

type RolepermissionService

type RolepermissionService interface {
	// get rolepermission by name
	GetByName(context.Context, *rolev3.RolePermission) (*rolev3.RolePermission, error)
	// list rolepermissions
	List(context.Context, ...query.Option) (*rolev3.RolePermissionList, error)
}

RolepermissionService is the interface for rolepermission operations

func NewRolepermissionService

func NewRolepermissionService(db *bun.DB) RolepermissionService

NewRolepermissionService return new rolepermission service

type UserService

type UserService interface {
	// create user
	Create(context.Context, *userv3.User) (*userv3.User, error)
	// get user by id
	GetByID(context.Context, *userv3.User) (*userv3.User, error)
	// get user by name
	GetByName(context.Context, *userv3.User) (*userv3.User, error)
	// get full user info
	GetUserInfo(context.Context, *userv3.User) (*userv3.UserInfo, error)
	// create or update user
	Update(context.Context, *userv3.User) (*userv3.User, error)
	// update user force reset flag
	UpdateForceResetFlag(context.Context, string) error
	// delete user
	Delete(context.Context, *userv3.User) (*userrpcv3.UserDeleteApiKeysResponse, error)
	// list users
	List(context.Context, ...query.Option) (*userv3.UserList, error)
	// retrieve the cli config for the logged in user
	RetrieveCliConfig(ctx context.Context, req *userrpcv3.ApiKeyRequest) (*common.CliConfigDownloadData, error)
	// Update UserGroup casbin for OIdC/Idp users
	UpdateIdpUserGroupPolicy(context.Context, string, string, string) error
	// Generate recovery link for users
	ForgotPassword(context.Context, *userrpcv3.UserForgotPasswordRequest) (*userrpcv3.UserForgotPasswordResponse, error)
	// Generate auditLog event
	CreateLoginAuditLog(context.Context, *userrpcv3.UserLoginAuditRequest) (*userrpcv3.UserLoginAuditResponse, error)
}

GroupService is the interface for group operations

Jump to

Keyboard shortcuts

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