authz

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckContext

func CheckContext(ctx context.Context, id sdktypes.ID, action string, opts ...func(*checkCfg)) error

func ContextWithCheckFunc

func ContextWithCheckFunc(ctx context.Context, check CheckFunc) context.Context

func DisableCheckForTesting

func DisableCheckForTesting()

func HTTPInterceptor

func HTTPInterceptor(checkFunc CheckFunc, h http.Handler) http.Handler

Enrich the request context with the check function.

func WithConvertForbiddenToNotFound

func WithConvertForbiddenToNotFound(cfg *checkCfg)

func WithNop

func WithNop(*checkCfg)

Types

type CheckFunc

type CheckFunc = func(ctx context.Context, id sdktypes.ID, action string, opts ...func(*checkCfg)) error

id: resource id to check access to. action: action to check access for. data: optional data to check access with (such as list filter).

func NewPolicyCheckFunc

func NewPolicyCheckFunc(l *zap.Logger, db db.DB, decide policy.DecideFunc) CheckFunc

PolicyCheckFunc is a function that checks access to a resource using a policy. Actions can be either of:

  • "some_action_name" -> {"action": "some_action_name", "action_type": ""}
  • "action_type:some_action_name" -> {"action": "some_action_name", "action_type": "action_type"}

type CheckOpt

type CheckOpt func(*checkCfg)

func WithAssociationWithID

func WithAssociationWithID(name string, id sdktypes.ID) CheckOpt

Set `data.associated_<name>_org_id` in the check context. This will cause the checker to automatically deduce what org it belongs to based on the ID.

func WithData

func WithData(k string, v any) CheckOpt

Set arbitrary data in check context.

Jump to

Keyboard shortcuts

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