scope

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FxGroup = "security-scope"
)

Variables

View Source
var (
	ErrNotInitialized             = fmt.Errorf("security scope manager is not initialied yet")
	ErrMissingDefaultSysAccount   = fmt.Errorf("unable to switch security scope: default system account is not configured")
	ErrMissingUser                = fmt.Errorf("unable to switch security scope: either username or user ID is required when not using default system account")
	ErrNotCurrentlyAuthenticated  = fmt.Errorf("unable to switch security scope without system account: current context is not authenticated")
	ErrUserIdAndUsernameExclusive = fmt.Errorf("invalid security scope option: username and user ID are exclusive")
	ErrTenantIdAndNameExclusive   = fmt.Errorf("invalid security scope option: tenant name and tenant ID are exclusive")
)
View Source
var Module = &bootstrap.Module{
	Name:       "security scope",
	Precedence: bootstrap.SecurityIntegrationPrecedence,
	Options: []fx.Option{
		fx.Provide(provideDefaultScopeManager),
		fx.Provide(tracingProvider()),
		fx.Invoke(configureScopeManagers),
	},
}

Functions

func Describe

func Describe(ctx context.Context) string

func Do

func Do(ctx context.Context, fn func(ctx context.Context), opts ...Options) error

Do invoke given function in a security scope specified by Options e.g.:

scope.Do(ctx, func(ctx context.Context) {
	// do something with ctx
}, scope.WithUsername("a-user"), scope.UseSystemAccount())

func FxManagerCustomizer added in v0.14.0

func FxManagerCustomizer(constructor interface{}) fx.Annotated

FxManagerCustomizer takes providers of ManagerCustomizer and wrap them with FxGroup

func Use

func Use()

Types

type ManagerCustomizer

type ManagerCustomizer interface {
	Customize() []ManagerOptions
}

type ManagerCustomizerFunc

type ManagerCustomizerFunc func() []ManagerOptions

func (ManagerCustomizerFunc) Customize

func (fn ManagerCustomizerFunc) Customize() []ManagerOptions

type ManagerOptions

type ManagerOptions func(opt *managerOption)

func AfterEndHook

func AfterEndHook(hook ScopeOperationHook) ManagerOptions

func BeforeStartHook

func BeforeStartHook(hook ScopeOperationHook) ManagerOptions

type Options

type Options func(*Scope)

func UseSystemAccount

func UseSystemAccount() Options

func WithTenantExternalId

func WithTenantExternalId(tenantExternalId string) Options

func WithTenantId

func WithTenantId(tenantId string) Options

func WithUserId

func WithUserId(userId string) Options

func WithUsername

func WithUsername(username string) Options

type Scope

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

func New

func New(opts ...Options) *Scope

func (*Scope) Do

func (s *Scope) Do(ctx context.Context, fn func(ctx context.Context)) (err error)

func (Scope) String

func (s Scope) String() string

type ScopeManager

type ScopeManager interface {
	StartScope(ctx context.Context, scope *Scope) (context.Context, error)
	Start(ctx context.Context, opts ...Options) (context.Context, error)
	End(ctx context.Context) context.Context
}

type ScopeOperationHook

type ScopeOperationHook func(ctx context.Context, scope *Scope) context.Context

Jump to

Keyboard shortcuts

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