resources

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: AGPL-3.0 Imports: 8 Imported by: 54

Documentation

Overview

Package resources provides ready-to-use SQL schemes and DAOs for attaching resource policies to any data

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDAO

func NewDAO(o dao.DAO, leftIdentifier string) dao.DAO

Types

type DAO

type DAO interface {
	AddPolicy(resourceId string, policy *service.ResourcePolicy) error
	AddPolicies(update bool, resourceId string, rules []*service.ResourcePolicy) error
	GetPoliciesForResource(resourceId string) ([]*service.ResourcePolicy, error)
	DeletePoliciesForResource(resourceId string) error
	DeletePoliciesForResourceAndAction(resourceId string, action service.ResourcePolicyAction) error
	DeletePoliciesBySubject(subject string) error

	BuildPolicyConditionForAction(q *service.ResourcePolicyQuery, action service.ResourcePolicyAction) (expr goqu.Expression, e error)
}

DAO interface

type ResourcesSQL

type ResourcesSQL struct {
	*sql.Handler

	LeftIdentifier string
}

Impl of the Mysql interface

func (*ResourcesSQL) AddPolicies

func (s *ResourcesSQL) AddPolicies(update bool, resourceId string, policies []*service.ResourcePolicy) error

AddPolicies persists a set of policies. If update is true, it replace them by deleting existing ones

func (*ResourcesSQL) AddPolicy

func (s *ResourcesSQL) AddPolicy(resourceId string, policy *service.ResourcePolicy) error

AddPolicy persists a policy in the underlying storage

func (*ResourcesSQL) BuildPolicyConditionForAction

func (s *ResourcesSQL) BuildPolicyConditionForAction(q *service.ResourcePolicyQuery, action service.ResourcePolicyAction) (expr goqu.Expression, e error)

BuildPolicyConditionForAction builds an ResourcesSQL condition from claims toward the associated resource table

func (*ResourcesSQL) DeletePoliciesBySubject

func (s *ResourcesSQL) DeletePoliciesBySubject(subject string) error

DeletePoliciesForResource removes all policies for a given resource

func (*ResourcesSQL) DeletePoliciesForResource

func (s *ResourcesSQL) DeletePoliciesForResource(resourceId string) error

DeletePoliciesForResource removes all policies for a given resource

func (*ResourcesSQL) DeletePoliciesForResourceAndAction

func (s *ResourcesSQL) DeletePoliciesForResourceAndAction(resourceId string, action service.ResourcePolicyAction) error

DeletePoliciesForResourceAndAction removes policies for a given resource only if they have the corresponding action

func (*ResourcesSQL) GetPoliciesForResource

func (s *ResourcesSQL) GetPoliciesForResource(resourceId string) ([]*service.ResourcePolicy, error)

GetPoliciesForResource finds all policies for a given resource

func (*ResourcesSQL) Init

func (s *ResourcesSQL) Init(options config.Map) error

Add to the mysql DB

Jump to

Keyboard shortcuts

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