authorizer

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GLOBAL_DEFAULT_ORG_ID = "_GlobalDefaultOrg"

	METADATA_KEY_ORGID            = "orgid"
	METADATA_KEY_ROLE             = "role"
	METADATA_ROLE_SERVICE_ADMIN   = "service_admin"
	METADATA_ROLE_SERVICE_AUDITOR = "service_auditor"
	METADATA_ROLE_ADMIN           = "admin"   // can be tenant_admin, *_admin
	METADATA_ROLE_AUDITOR         = "auditor" // can be tenant_auditor, *_auditor
)
View Source
const (
	INSTANCE_ID = ContextKey("multiinstance.id")
)
View Source
const (
	TransactionCtx = TransactionContextKey("DB_TRANSACTION")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorizer

type Authorizer interface {
	Tenancer
	Configure(tableName string, roleMapping map[string]dbrole.DbRole)
	GetAuthContext(orgId string, roles ...string) context.Context
	GetDefaultOrgAdminContext() context.Context
	GetMatchingDbRole(ctx context.Context, tableNames ...string) (dbrole.DbRole, error)
}

Authorizer Interface defines the methods required for datastore to restrict access based on roles configured in context.

type ContextKey added in v0.0.5

type ContextKey string

type Instancer added in v0.0.5

type Instancer interface {
	GetInstanceId(ctx context.Context) (string, error)
	WithInstanceId(ctx context.Context, instanceId string) context.Context
}

type MetadataBasedAuthorizer

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

func (*MetadataBasedAuthorizer) Configure

func (s *MetadataBasedAuthorizer) Configure(tableName string, roleMapping map[string]dbrole.DbRole)

func (*MetadataBasedAuthorizer) GetAuthContext

func (s *MetadataBasedAuthorizer) GetAuthContext(orgId string, roles ...string) context.Context

func (*MetadataBasedAuthorizer) GetDefaultOrgAdminContext

func (s *MetadataBasedAuthorizer) GetDefaultOrgAdminContext() context.Context

func (*MetadataBasedAuthorizer) GetMatchingDbRole

func (s *MetadataBasedAuthorizer) GetMatchingDbRole(ctx context.Context, tableNames ...string) (dbrole.DbRole, error)

func (*MetadataBasedAuthorizer) GetOrgFromContext

func (s *MetadataBasedAuthorizer) GetOrgFromContext(ctx context.Context) (string, error)

type SimpleInstancer added in v0.0.5

type SimpleInstancer struct{}

func (*SimpleInstancer) GetInstanceId added in v0.0.5

func (s *SimpleInstancer) GetInstanceId(ctx context.Context) (string, error)

func (*SimpleInstancer) WithInstanceId added in v0.0.5

func (s *SimpleInstancer) WithInstanceId(ctx context.Context, instanceId string) context.Context

type SimpleTransactionFetcher added in v0.0.9

type SimpleTransactionFetcher struct{}

func (SimpleTransactionFetcher) GetTransactionCtx added in v0.0.9

func (s SimpleTransactionFetcher) GetTransactionCtx(ctx context.Context) *gorm.DB

func (SimpleTransactionFetcher) IsTransactionCtx added in v0.0.9

func (s SimpleTransactionFetcher) IsTransactionCtx(ctx context.Context) bool

func (SimpleTransactionFetcher) WithTransactionCtx added in v0.0.9

func (s SimpleTransactionFetcher) WithTransactionCtx(ctx context.Context, tx *gorm.DB) context.Context

type Tenancer added in v0.0.5

type Tenancer interface {
	GetOrgFromContext(ctx context.Context) (string, error)
}

type TransactionContextKey added in v0.0.9

type TransactionContextKey string

type TransactionFetcher added in v0.0.9

type TransactionFetcher interface {
	IsTransactionCtx(ctx context.Context) bool
	GetTransactionCtx(ctx context.Context) *gorm.DB
	WithTransactionCtx(ctx context.Context, tx *gorm.DB) context.Context
}

Jump to

Keyboard shortcuts

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