authz

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Authorized = "Authorized"
View Source
const NotAuthorized = "Not Authorized"

Variables

This section is empty.

Functions

func AuthorizeHandler added in v0.11.0

func AuthorizeHandler(svc CheckService, w http.ResponseWriter, r *http.Request) error

func NewPipeline added in v0.31.0

func NewPipeline(maxServiceConcurrency int, maxSubtaskConcurrency int) *pipeline

Types

type CheckContextFunc added in v0.32.2

type CheckContextFunc func(ctx context.Context) (context.Context, error)

type CheckManySpec

type CheckManySpec struct {
	Op       string                `json:"op"`
	Warrants []CheckWarrantSpec    `json:"warrants" validate:"min=1,dive"`
	Context  warrant.PolicyContext `json:"context"`
	Debug    bool                  `json:"debug"`
}

func (CheckManySpec) ToMap

func (spec CheckManySpec) ToMap() map[string]interface{}

type CheckResultSpec

type CheckResultSpec struct {
	Code           int64                            `json:"code,omitempty"`
	Result         string                           `json:"result"`
	ProcessingTime int64                            `json:"processingTime,omitempty"`
	DecisionPath   map[string][]warrant.WarrantSpec `json:"decisionPath,omitempty"`
}

type CheckService

type CheckService struct {
	service.BaseService
	WarrantRepository  warrant.WarrantRepository
	EventSvc           event.Service
	ObjectTypeSvc      *objecttype.ObjectTypeService
	CheckConfig        *config.CheckConfig
	CreateCheckContext CheckContextFunc
}

func NewService

func NewService(env service.Env, warrantRepo warrant.WarrantRepository, eventSvc event.Service, objectTypeSvc *objecttype.ObjectTypeService, checkConfig *config.CheckConfig, checkContext CheckContextFunc) *CheckService

func (CheckService) Check

func (svc CheckService) Check(ctx context.Context, authInfo *service.AuthInfo, warrantCheck CheckSpec) (bool, []warrant.WarrantSpec, error)

Check returns true if the subject has a warrant (explicitly or implicitly) for given objectType:objectId#relation and context.

func (CheckService) CheckMany

func (svc CheckService) CheckMany(ctx context.Context, authInfo *service.AuthInfo, warrantCheck *CheckManySpec) (*CheckResultSpec, error)

func (CheckService) Routes added in v0.8.0

func (svc CheckService) Routes() ([]service.Route, error)

type CheckSessionWarrantSpec added in v0.18.0

type CheckSessionWarrantSpec struct {
	ObjectType string                `json:"objectType" validate:"required,valid_object_type"`
	ObjectId   string                `json:"objectId" validate:"required,valid_object_id"`
	Relation   string                `json:"relation" validate:"required,valid_relation"`
	Context    warrant.PolicyContext `json:"context"`
}

func (CheckSessionWarrantSpec) ToMap added in v0.18.0

func (spec CheckSessionWarrantSpec) ToMap() map[string]interface{}

type CheckSpec

type CheckSpec struct {
	CheckWarrantSpec
	Debug bool `json:"debug" validate:"boolean"`
}

func (CheckSpec) ToMap

func (spec CheckSpec) ToMap() map[string]interface{}

type CheckWarrantSpec added in v0.18.0

type CheckWarrantSpec struct {
	ObjectType string                `json:"objectType" validate:"required,valid_object_type"`
	ObjectId   string                `json:"objectId" validate:"required,valid_object_id"`
	Relation   string                `json:"relation" validate:"required,valid_relation"`
	Subject    *warrant.SubjectSpec  `json:"subject" validate:"required"`
	Context    warrant.PolicyContext `json:"context"`
}

func (CheckWarrantSpec) String added in v0.18.0

func (spec CheckWarrantSpec) String() string

func (CheckWarrantSpec) ToMap added in v0.18.0

func (spec CheckWarrantSpec) ToMap() map[string]interface{}

type SessionCheckManySpec added in v0.7.0

type SessionCheckManySpec struct {
	Op       string                    `json:"op"`
	Warrants []CheckSessionWarrantSpec `json:"warrants" validate:"min=1,dive"`
	Context  warrant.PolicyContext     `json:"context"`
	Debug    bool                      `json:"debug"`
}

func (SessionCheckManySpec) ToMap added in v0.18.0

func (spec SessionCheckManySpec) ToMap() map[string]interface{}

Jump to

Keyboard shortcuts

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