schema

package
v0.6.20 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// namespace
	OrganizationNamespace   = "shield/organization"
	ProjectNamespace        = "shield/project"
	GroupNamespace          = "shield/group"
	ServiceDataKeyNamespace = "shield/servicedata_key"

	// relation
	OrganizationRelationName = "organization"
	ProjectRelationName      = "project"
	GroupRelationName        = "group"

	// roles
	OwnerRole   = "owner"
	EditorRole  = "editor"
	ViewerRole  = "viewer"
	ManagerRole = "manager"
	MemberRole  = "member"

	// permissions
	ViewPermission   = "view"
	EditPermission   = "edit"
	DeletePermission = "delete"

	// synthetic permission
	MembershipPermission = "membership"

	// principals
	UserPrincipal  = "shield/user"
	GroupPrincipal = "shield/group"
)

SpiceDB readable format is stored in predefined_schema.txt

Variables

Functions

func AppendIfUnique

func AppendIfUnique[T comparable](slice1 []T, slice2 []T) []T

func Contains

func Contains[T comparable](s []T, e T) bool

func GetNamespace

func GetNamespace(namespaceID string) string

func GetRoleID

func GetRoleID(n, r string) string

func GetRoleName

func GetRoleName(r string) string

func PermissionInheritanceFormatter

func PermissionInheritanceFormatter(permissionName, namespaceName string) string

func SpiceDBPermissionInheritanceFormatter

func SpiceDBPermissionInheritanceFormatter(roleName string) string

Types

type ActionService

type ActionService interface {
	Create(ctx context.Context, action action.Action) (action.Action, error)
}

type AuthzEngine

type AuthzEngine interface {
	WriteSchema(ctx context.Context, schema NamespaceConfigMapType) error
}

type FileService

type FileService interface {
	GetSchema(ctx context.Context) (NamespaceConfigMapType, error)
}

type InheritedNamespace

type InheritedNamespace struct {
	Name        string
	NamespaceId string
}

type NamespaceConfig

type NamespaceConfig struct {
	InheritedNamespaces []InheritedNamespace
	Type                NamespaceType
	Roles               map[string][]string
	Permissions         map[string][]string
}

type NamespaceConfigMapType

type NamespaceConfigMapType map[string]NamespaceConfig

func MergeNamespaceConfigMap

func MergeNamespaceConfigMap(smallMap, largeMap NamespaceConfigMapType) NamespaceConfigMapType

type NamespaceService

type NamespaceService interface {
	Create(ctx context.Context, ns namespace.Namespace) (namespace.Namespace, error)
}

type NamespaceType

type NamespaceType string
var (
	SystemNamespace        NamespaceType = "system_namespace"
	ResourceGroupNamespace NamespaceType = "resource_group_namespace"

	ErrMigration = errors.New("error in migrating authz schema")
)

type PolicyService

type PolicyService interface {
	Create(ctx context.Context, policy policy.Policy) ([]policy.Policy, error)
}

type RoleService

type RoleService interface {
	Create(ctx context.Context, toCreate role.Role) (role.Role, error)
}

type SchemaMigrationConfig added in v0.6.15

type SchemaMigrationConfig struct {
	DefaultSystemEmail      string
	BootstrapServiceDataKey bool
}

func NewSchemaMigrationConfig added in v0.6.15

func NewSchemaMigrationConfig(defaultSystemEmail string, bootstrapServiceDataKey bool) SchemaMigrationConfig

type SchemaService

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

func NewSchemaMigrationService

func NewSchemaMigrationService(
	schemaConfig FileService,
	namespaceService NamespaceService,
	roleService RoleService,
	actionService ActionService,
	policyService PolicyService,
	authzEngine AuthzEngine,
	userRepository UserRepository,
	schemaMigrationConfig SchemaMigrationConfig) *SchemaService

func (SchemaService) RunMigrations

func (s SchemaService) RunMigrations(ctx context.Context) error

type UserRepository added in v0.6.15

type UserRepository interface {
	Create(ctx context.Context, usr user.User) (user.User, error)
	GetByEmail(ctx context.Context, email string) (user.User, error)
}

Jump to

Keyboard shortcuts

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