db

package
v0.0.0-...-794f3e4 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDataStore

func CreateDataStore(cfg *domain.Config) (repository.DataStore, error)

CreateDataStore factory

func CreateDatabaseAuthService

func CreateDatabaseAuthService(
	cfg *domain.Config,
	metricsRegistry *metrics.Registry,
) (service.AuthAdminService, domain.Closeable, error)

CreateDatabaseAuthService factory method

func NewAuthAdminServiceDB

func NewAuthAdminServiceDB(
	config *domain.Config,
	metricsRegistry *metrics.Registry,
	orgRepository repository.Repository[types.Organization],
	principalRepository repository.Repository[types.Principal],
	groupsRepository repository.Repository[types.Group],
	permissionRepository repository.Repository[types.Permission],
	relationshipRepository repository.Repository[types.Relationship],
	resourceRepository repository.Repository[types.Resource],
	resourceInstanceRepositoryFactory repository.ResourceInstanceRepositoryFactory,
	roleRepository repository.Repository[types.Role],
	hashRepository repository.Repository[domain.HashIndex],
	maxCacheSize int,
	cacheExpirationMillis int,
) *authAdminServiceDB

NewAuthAdminServiceDB manages persistence of AuthZ data

Types

type GroupServiceDB

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

GroupServiceDB - manages persistence of groups data

func NewGroupServiceDB

func NewGroupServiceDB(
	metricsRegistry *metrics.Registry,
	orgService *OrganizationServiceDB,
	groupsRepository repository.Repository[types.Group],
	hashRepository repository.Repository[domain.HashIndex],
) *GroupServiceDB

NewGroupServiceDB manages persistence of groups data

func (*GroupServiceDB) AddRolesToGroup

func (s *GroupServiceDB) AddRolesToGroup(
	ctx context.Context,
	organizationID string,
	namespace string,
	groupID string,
	roleIDs ...string,
) error

AddRolesToGroup helper

func (*GroupServiceDB) CreateGroup

func (s *GroupServiceDB) CreateGroup(
	ctx context.Context,
	organizationID string,
	group *types.Group) (*types.Group, error)

CreateGroup - creates a new group Note: Redis doesn't allow optimistic concurrency check based on version, so it's possible to have duplicate groups records.

func (*GroupServiceDB) DeleteGroup

func (s *GroupServiceDB) DeleteGroup(
	ctx context.Context,
	organizationID string,
	namespace string,
	id string) error

DeleteGroup removes group

func (*GroupServiceDB) DeleteRolesToGroup

func (s *GroupServiceDB) DeleteRolesToGroup(
	ctx context.Context,
	organizationID string,
	namespace string,
	groupID string,
	roleIDs ...string,
) error

DeleteRolesToGroup helper

func (*GroupServiceDB) GetGroup

func (s *GroupServiceDB) GetGroup(
	ctx context.Context,
	organizationID string,
	namespace string,
	id string,
) (*types.Group, error)

GetGroup - finds group

func (*GroupServiceDB) GetGroups

func (s *GroupServiceDB) GetGroups(
	ctx context.Context,
	organizationID string,
	namespace string,
	predicate map[string]string,
	offset string,
	limit int64) (res []*types.Group, nextOffset string, err error)

GetGroups - queries groups

func (*GroupServiceDB) UpdateGroup

func (s *GroupServiceDB) UpdateGroup(
	ctx context.Context,
	organizationID string,
	group *types.Group) error

UpdateGroup - updates an existing group Note: Redis doesn't allow optimistic concurrency check based on version, so it's possible to have duplicate groups records.

type OrganizationServiceDB

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

OrganizationServiceDB - manages persistence of AuthZ data

func NewOrganizationServiceDB

func NewOrganizationServiceDB(
	metricsRegistry *metrics.Registry,
	orgRepository repository.Repository[types.Organization],
	maxCacheSize int,
	cacheExpirationMillis int,
) *OrganizationServiceDB

NewOrganizationServiceDB manages persistence of organization

func (*OrganizationServiceDB) CreateOrganization

func (s *OrganizationServiceDB) CreateOrganization(
	ctx context.Context,
	org *types.Organization) (*types.Organization, error)

CreateOrganization - adds an organization

func (*OrganizationServiceDB) DeleteOrganization

func (s *OrganizationServiceDB) DeleteOrganization(
	ctx context.Context,
	id string) error

func (*OrganizationServiceDB) GetOrganization

func (s *OrganizationServiceDB) GetOrganization(
	ctx context.Context,
	id string) (org *types.Organization, err error)

GetOrganization finds organization

func (*OrganizationServiceDB) GetOrganizations

func (s *OrganizationServiceDB) GetOrganizations(
	ctx context.Context,
	predicate map[string]string,
	offset string,
	limit int64) (res []*types.Organization, nextToken string, err error)

GetOrganizations - queries organizations

func (*OrganizationServiceDB) UpdateOrganization

func (s *OrganizationServiceDB) UpdateOrganization(
	ctx context.Context,
	org *types.Organization) error

UpdateOrganization - updates organization

type PermissionServiceDB

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

PermissionServiceDB - manages persistence of permission data

func NewPermissionServiceDB

func NewPermissionServiceDB(
	metricsRegistry *metrics.Registry,
	orgService *OrganizationServiceDB,
	resourceRepository repository.Repository[types.Resource],
	permissionRepository repository.Repository[types.Permission],
	hashRepository repository.Repository[domain.HashIndex],
) *PermissionServiceDB

NewPermissionServiceDB manages persistence of permission data

func (*PermissionServiceDB) CreatePermission

func (s *PermissionServiceDB) CreatePermission(
	ctx context.Context,
	organizationID string,
	permission *types.Permission) (*types.Permission, error)

CreatePermission - creates a new permission

func (*PermissionServiceDB) DeletePermission

func (s *PermissionServiceDB) DeletePermission(
	ctx context.Context,
	organizationID string,
	namespace string,
	id string) error

DeletePermission removes permission

func (*PermissionServiceDB) GetPermission

func (s *PermissionServiceDB) GetPermission(
	ctx context.Context,
	organizationID string,
	namespace string,
	id string,
) (*types.Permission, error)

GetPermission - finds permission

func (*PermissionServiceDB) GetPermissions

func (s *PermissionServiceDB) GetPermissions(
	ctx context.Context,
	organizationID string,
	namespace string,
	predicate map[string]string,
	offset string,
	limit int64) (res []*types.Permission, nextToken string, err error)

GetPermissions - queries permissions

func (*PermissionServiceDB) UpdatePermission

func (s *PermissionServiceDB) UpdatePermission(
	ctx context.Context,
	organizationID string,
	permission *types.Permission) error

UpdatePermission - updates an existing permission

type PrincipalServiceDB

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

PrincipalServiceDB - manages persistence of principal objects

func NewPrincipalServiceDB

func NewPrincipalServiceDB(
	config *domain.Config,
	metricsRegistry *metrics.Registry,
	orgService *OrganizationServiceDB,
	principalRepository repository.Repository[types.Principal],
	groupsRepository repository.Repository[types.Group],
	permissionRepository repository.Repository[types.Permission],
	relationshipRepository repository.Repository[types.Relationship],
	resourceRepository repository.Repository[types.Resource],
	roleRepository repository.Repository[types.Role],
	hashRepository repository.Repository[domain.HashIndex],
	maxCacheSize int,
	cacheExpirationMillis int,
) *PrincipalServiceDB

NewPrincipalServiceDB manages persistence of principal data

func (*PrincipalServiceDB) AddGroupsToPrincipal

func (s *PrincipalServiceDB) AddGroupsToPrincipal(
	ctx context.Context,
	organizationID string,
	namespace string,
	principalID string,
	groupIDs ...string,
) error

AddGroupsToPrincipal helper

func (*PrincipalServiceDB) AddPermissionsToPrincipal

func (s *PrincipalServiceDB) AddPermissionsToPrincipal(
	ctx context.Context,
	organizationID string,
	namespace string,
	principalID string,
	permissionIds ...string,
) error

AddPermissionsToPrincipal helper

func (*PrincipalServiceDB) AddRelationshipsToPrincipal

func (s *PrincipalServiceDB) AddRelationshipsToPrincipal(
	ctx context.Context,
	organizationID string,
	namespace string,
	principalID string,
	relationshipIds ...string,
) error

AddRelationshipsToPrincipal helper

func (*PrincipalServiceDB) AddRolesToPrincipal

func (s *PrincipalServiceDB) AddRolesToPrincipal(
	ctx context.Context,
	organizationID string,
	namespace string,
	principalID string,
	roleIDs ...string,
) error

AddRolesToPrincipal helper

func (*PrincipalServiceDB) CreatePrincipal

func (s *PrincipalServiceDB) CreatePrincipal(
	ctx context.Context,
	principal *types.Principal) (*types.Principal, error)

CreatePrincipal - creates new instance of principal Note - this method won't be used to update any role-ids, group-ids, relations, and permission-ids

func (*PrincipalServiceDB) DeleteGroupsToPrincipal

func (s *PrincipalServiceDB) DeleteGroupsToPrincipal(
	ctx context.Context,
	organizationID string,
	namespace string,
	principalID string,
	groupIDs ...string,
) error

DeleteGroupsToPrincipal helper

func (*PrincipalServiceDB) DeletePermissionsToPrincipal

func (s *PrincipalServiceDB) DeletePermissionsToPrincipal(
	ctx context.Context,
	organizationID string,
	namespace string,
	principalID string,
	permissionIds ...string,
) error

DeletePermissionsToPrincipal helper

func (*PrincipalServiceDB) DeletePrincipal

func (s *PrincipalServiceDB) DeletePrincipal(
	ctx context.Context,
	organizationID string,
	id string) error

DeletePrincipal removes principal

func (*PrincipalServiceDB) DeleteRelationshipsToPrincipal

func (s *PrincipalServiceDB) DeleteRelationshipsToPrincipal(
	ctx context.Context,
	organizationID string,
	namespace string,
	principalID string,
	relationshipIds ...string,
) error

DeleteRelationshipsToPrincipal helper

func (*PrincipalServiceDB) DeleteRolesToPrincipal

func (s *PrincipalServiceDB) DeleteRolesToPrincipal(
	ctx context.Context,
	organizationID string,
	namespace string,
	principalID string,
	roleIDs ...string,
) error

DeleteRolesToPrincipal helper

func (*PrincipalServiceDB) GetPrincipal

func (s *PrincipalServiceDB) GetPrincipal(
	ctx context.Context,
	organizationID string,
	id string,
) (*types.Principal, error)

GetPrincipal - retrieves principal

func (*PrincipalServiceDB) GetPrincipalExt

func (s *PrincipalServiceDB) GetPrincipalExt(
	ctx context.Context,
	organizationID string,
	namespace string,
	id string,
) (xPrincipal *domain.PrincipalExt, err error)

GetPrincipalExt - retrieves full principal

func (*PrincipalServiceDB) GetPrincipals

func (s *PrincipalServiceDB) GetPrincipals(
	ctx context.Context,
	organizationID string,
	predicates map[string]string,
	offset string,
	limit int64) (res []*types.Principal, nextToken string, err error)

GetPrincipals - queries principals

func (*PrincipalServiceDB) UpdatePrincipal

func (s *PrincipalServiceDB) UpdatePrincipal(
	ctx context.Context,
	principal *types.Principal) error

UpdatePrincipal - updates existing instance of principal Note - this method won't be used to update any role-ids, group-ids, relations, and permission-ids

type RelationshipServiceDB

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

RelationshipServiceDB - manages persistence of relationship data

func NewRelationshipServiceDB

func NewRelationshipServiceDB(
	metricsRegistry *metrics.Registry,
	orgService *OrganizationServiceDB,
	relationshipRepository repository.Repository[types.Relationship],
	hashRepository repository.Repository[domain.HashIndex],
) *RelationshipServiceDB

NewRelationshipServiceDB manages persistence of relationship data

func (*RelationshipServiceDB) CreateRelationship

func (s *RelationshipServiceDB) CreateRelationship(
	ctx context.Context,
	organizationID string,
	relationship *types.Relationship) (*types.Relationship, error)

CreateRelationship - creates a new relationship

func (*RelationshipServiceDB) DeleteRelationship

func (s *RelationshipServiceDB) DeleteRelationship(
	ctx context.Context,
	organizationID string,
	namespace string,
	id string) error

DeleteRelationship removes relationship

func (*RelationshipServiceDB) GetRelationship

func (s *RelationshipServiceDB) GetRelationship(
	ctx context.Context,
	organizationID string,
	namespace string,
	id string,
) (*types.Relationship, error)

GetRelationship - finds relationship

func (*RelationshipServiceDB) GetRelationships

func (s *RelationshipServiceDB) GetRelationships(
	ctx context.Context,
	organizationID string,
	namespace string,
	predicate map[string]string,
	offset string,
	limit int64) (res []*types.Relationship, nextOffset string, err error)

GetRelationships - queries relationships

func (*RelationshipServiceDB) UpdateRelationship

func (s *RelationshipServiceDB) UpdateRelationship(
	ctx context.Context,
	organizationID string,
	relationship *types.Relationship) error

UpdateRelationship - updates an existing relationship

type ResourceServiceDB

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

ResourceServiceDB - manages persistence of resources and resource instances

func NewResourceServiceDB

func NewResourceServiceDB(
	metricsRegistry *metrics.Registry,
	orgService *OrganizationServiceDB,
	principalService *PrincipalServiceDB,
	resourceRepository repository.Repository[types.Resource],
	resourceInstanceRepositoryFactory repository.ResourceInstanceRepositoryFactory,
	hashRepository repository.Repository[domain.HashIndex],
) *ResourceServiceDB

NewResourceServiceDB manages persistence of resources

func (*ResourceServiceDB) AllocateResourceInstance

func (s *ResourceServiceDB) AllocateResourceInstance(
	ctx context.Context,
	organizationID string,
	namespace string,
	resourceID string,
	principalID string,
	constraints string,
	expiry time.Duration,
	context map[string]string,
) error

AllocateResourceInstance - allocates resource-instance

func (*ResourceServiceDB) CountResourceInstances

func (s *ResourceServiceDB) CountResourceInstances(
	ctx context.Context,
	organizationID string,
	namespace string,
	resourceID string,
) (capacity int32, allocated int32, err error)

CountResourceInstances - size of total and allocated resource-instances

func (*ResourceServiceDB) CreateResource

func (s *ResourceServiceDB) CreateResource(
	ctx context.Context,
	organizationID string,
	resource *types.Resource) (*types.Resource, error)

CreateResource - creates a new instance of resource

func (*ResourceServiceDB) DeallocateResourceInstance

func (s *ResourceServiceDB) DeallocateResourceInstance(
	ctx context.Context,
	organizationID string,
	namespace string,
	resourceID string,
	principalID string,
) error

DeallocateResourceInstance - deallocates resource-instance

func (*ResourceServiceDB) DeleteResource

func (s *ResourceServiceDB) DeleteResource(
	ctx context.Context,
	organizationID string,
	namespace string,
	id string) error

DeleteResource removes resource

func (*ResourceServiceDB) GetResource

func (s *ResourceServiceDB) GetResource(
	ctx context.Context,
	organizationID string,
	namespace string,
	id string,
) (*types.Resource, error)

GetResource - finds resource

func (*ResourceServiceDB) QueryResourceInstances

func (s *ResourceServiceDB) QueryResourceInstances(
	ctx context.Context,
	organizationID string,
	namespace string,
	resourceID string,
	predicate map[string]string,
	offset string,
	limit int64) (res []*types.ResourceInstance, nextOffset string, err error)

QueryResourceInstances - queries resource-instances

func (*ResourceServiceDB) QueryResources

func (s *ResourceServiceDB) QueryResources(
	ctx context.Context,
	organizationID string,
	namespace string,
	predicate map[string]string,
	offset string,
	limit int64) (res []*types.Resource, nextOffset string, err error)

QueryResources - queries resources by predicates.

func (*ResourceServiceDB) UpdateResource

func (s *ResourceServiceDB) UpdateResource(
	ctx context.Context,
	organizationID string,
	resource *types.Resource) error

UpdateResource - updates an existing resource

type RoleServiceDB

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

RoleServiceDB - manages persistence of roles data

func NewRoleServiceDB

func NewRoleServiceDB(
	metricsRegistry *metrics.Registry,
	orgService *OrganizationServiceDB,
	roleRepository repository.Repository[types.Role],
	hashRepository repository.Repository[domain.HashIndex],
) *RoleServiceDB

NewRoleServiceDB manages persistence of roles data

func (*RoleServiceDB) AddPermissionsToRole

func (s *RoleServiceDB) AddPermissionsToRole(
	ctx context.Context,
	organizationID string,
	namespace string,
	roleID string,
	permissionIds ...string,
) error

AddPermissionsToRole helper

func (*RoleServiceDB) CreateRole

func (s *RoleServiceDB) CreateRole(
	ctx context.Context,
	organizationID string,
	role *types.Role) (*types.Role, error)

CreateRole - creates a new role

func (*RoleServiceDB) DeletePermissionsToRole

func (s *RoleServiceDB) DeletePermissionsToRole(
	ctx context.Context,
	organizationID string,
	namespace string,
	roleID string,
	permissionIds ...string,
) error

DeletePermissionsToRole helper

func (*RoleServiceDB) DeleteRole

func (s *RoleServiceDB) DeleteRole(
	ctx context.Context,
	organizationID string,
	namespace string,
	id string) error

DeleteRole removes role

func (*RoleServiceDB) GetRole

func (s *RoleServiceDB) GetRole(
	ctx context.Context,
	organizationID string,
	namespace string,
	id string,
) (*types.Role, error)

GetRole - finds role

func (*RoleServiceDB) GetRoles

func (s *RoleServiceDB) GetRoles(
	ctx context.Context,
	organizationID string,
	namespace string,
	predicate map[string]string,
	offset string,
	limit int64) (res []*types.Role, nextOffset string, err error)

GetRoles - queries roles

func (*RoleServiceDB) UpdateRole

func (s *RoleServiceDB) UpdateRole(
	ctx context.Context,
	organizationID string,
	role *types.Role) error

UpdateRole - updates an existing role

Jump to

Keyboard shortcuts

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