policy

package
v0.0.0-...-7b7c10a Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAllowed = errors.New("not allowed")

ErrNotAllowed is returned when a subject DID is not allowed to proceed under the given policy.

Functions

This section is empty.

Types

type Policy

type Policy struct {
	// Policy ID.
	ID string `json:"id"`
	// A list of DIDs identifying the entities collecting sensitive data and permitted to protect those objects with
	// this policy.
	Collectors []string `json:"collectors"`
	// A list of DIDs identifying the entities permitted to request the release of protected objects associated with
	// this policy.
	Handlers []string `json:"handlers"`
	// A list of DIDs identifying entities required to provide authorization for the release of the protected object.
	Approvers []string `json:"approvers"`
	// The minimum number of (unique) approvers required before an object may be released back to the handler.
	// This allows for an "m of N" approval scenario. Constraints: 0 < min_approvers < approvers.length.
	MinApprovers int `json:"min_approvers"`
}

Policy contains policy configuration for storing and releasing protected data.

type Role

type Role int

Role is a role of entity represented by DID.

const (
	// Collector represents an entity that collects sensitive data.
	Collector Role = iota
	// Handler represents an entity that is permitted to request the release of protected data.
	Handler
	// Approver represents an entity that provides authorization for the release of the protected data.
	Approver
)

type Service

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

Service works with policy configurations.

func NewService

func NewService(storeProvider storage.Provider) (*Service, error)

NewService returns a new instance of Service.

func (*Service) Check

func (s *Service) Check(_ context.Context, policyID, did string, role Role) error

Check checks if DID is allowed to proceed under the given policy.

func (*Service) Get

func (s *Service) Get(_ context.Context, policyID string) (*Policy, error)

Get gets policy from the underlying storage by ID.

func (*Service) Save

func (s *Service) Save(_ context.Context, doc *Policy) error

Save stores policy configuration.

Jump to

Keyboard shortcuts

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