Documentation
¶
Index ¶
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func MustAsset(name string) []byte
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type ErrEvaluation
- type ErrUnexpectedResultExpression
- type ErrUnexpectedResultSet
- type OptFunc
- type State
- func (s *State) DumpData(ctx context.Context) error
- func (s *State) FilterAuthorizedPairs(ctx context.Context, subjects engine.Subjects, pairs []engine.Pair) ([]engine.Pair, error)
- func (s *State) IsAuthorized(ctx context.Context, subjects engine.Subjects, action engine.Action, ...) (bool, error)
- func (s *State) ListProjectMappings(ctx context.Context) (map[string][]engine.Rule, error)
- func (s *State) RulesForProject(ctx context.Context, projectID string) ([]engine.Rule, error)
- func (s *State) SetPolicies(ctx context.Context, policies map[string]interface{}) error
- func (s *State) V2FilterAuthorizedPairs(ctx context.Context, subjects engine.Subjects, pairs []engine.Pair) ([]engine.Pair, error)
- func (s *State) V2FilterAuthorizedProjects(ctx context.Context, subjects engine.Subjects, pairs []engine.Pair) ([]string, error)
- func (s *State) V2IsAuthorized(ctx context.Context, subjects engine.Subjects, action engine.Action, ...) (bool, error)
- func (s *State) V2ProjectsAuthorized(ctx context.Context, subjects engine.Subjects, action engine.Action, ...) ([]string, error)
- func (s *State) V2SetPolicies(ctx context.Context, policyMap map[string]interface{}, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
Types ¶
type ErrEvaluation ¶
type ErrEvaluation struct {
// contains filtered or unexported fields
}
ErrEvaluation is returned when a query evaluation returns an error.
func (*ErrEvaluation) Error ¶
func (e *ErrEvaluation) Error() string
type ErrUnexpectedResultExpression ¶
type ErrUnexpectedResultExpression struct {
// contains filtered or unexported fields
}
ErrUnexpectedResultExpression is returned when one of the result sets expressions can't be made sense of
func (*ErrUnexpectedResultExpression) Error ¶
func (e *ErrUnexpectedResultExpression) Error() string
type ErrUnexpectedResultSet ¶
type ErrUnexpectedResultSet struct {
// contains filtered or unexported fields
}
ErrUnexpectedResultSet is returned when the result set of an OPA query can't be made sense of
func (*ErrUnexpectedResultSet) Error ¶
func (e *ErrUnexpectedResultSet) Error() string
type OptFunc ¶
type OptFunc func(*State)
OptFunc is the type of functional options to be passed to New()
type State ¶
type State struct {
// contains filtered or unexported fields
}
State wraps the state of OPA we need to track
func New ¶
New initializes a fresh OPA state, using the default, hardcoded OPA policy from policy/authz*.rego unless overridden via an opa.OptFunc.
func (*State) DumpData ¶
DumpData is a bit fast-and-loose when it comes to error checking; it's not meant to be used in production
func (*State) FilterAuthorizedPairs ¶
func (s *State) FilterAuthorizedPairs( ctx context.Context, subjects engine.Subjects, pairs []engine.Pair) ([]engine.Pair, error)
FilterAuthorizedPairs passes the pairs into OPA, lets it take care of the filtering, and returns the result (sub)list
func (*State) IsAuthorized ¶
func (s *State) IsAuthorized( ctx context.Context, subjects engine.Subjects, action engine.Action, resource engine.Resource) (bool, error)
IsAuthorized evaluates whether a given [subject, resource, action] tuple is authorized given the service's state
func (*State) ListProjectMappings ¶
ListProjectMappings returns a map of all the rules for each projectID.
func (*State) RulesForProject ¶
Note(sr) Right now, it doesn't seem like this was doing much more than retrieving data from OPA's store. However, that's fine -- we'll need those mapping rules in OPA's store for other things (most likely), so retrieving them from there is a decent approximation of our approach.
func (*State) SetPolicies ¶
SetPolicies replaces OPA's data with a new set of policies, and resets the partial evaluation cache
func (*State) V2FilterAuthorizedPairs ¶
func (s *State) V2FilterAuthorizedPairs( ctx context.Context, subjects engine.Subjects, pairs []engine.Pair) ([]engine.Pair, error)
V2FilterAuthorizedPairs passes the pairs into OPA, lets it take care of the filtering, and returns the result (sub)list
func (*State) V2FilterAuthorizedProjects ¶
func (s *State) V2FilterAuthorizedProjects( ctx context.Context, subjects engine.Subjects, pairs []engine.Pair) ([]string, error)
V2FilterAuthorizedProjects passes the pairs of all action/resources into OPA, lets it take care of the filtering, and returns the projects associated with the resulting (sub)list.
func (*State) V2IsAuthorized ¶
func (s *State) V2IsAuthorized( ctx context.Context, subjects engine.Subjects, action engine.Action, resource engine.Resource) (bool, error)
V2IsAuthorized evaluates whether a given [subject, resource, action] tuple is authorized given the service's state
func (*State) V2ProjectsAuthorized ¶
func (s *State) V2ProjectsAuthorized( ctx context.Context, subjects engine.Subjects, action engine.Action, resource engine.Resource, projects engine.Projects) ([]string, error)
V2ProjectsAuthorized evaluates whether a given [subject, resource, action, projects] tuple is authorized and returns the list of associated allowed projects from the set of requested projects passed in.
func (*State) V2SetPolicies ¶
func (s *State) V2SetPolicies( ctx context.Context, policyMap map[string]interface{}, roleMap map[string]interface{}, ruleMap map[string][]interface{}) error
Spike TODO: Can we have a separate method for just setting the rule mappings? OR does the entire OPA store have to be re-evaluated at once. IF that's true, should we have the same OPA instance in general for rules?
V2SetPolicies replaces OPA's data with a new set of policies and roles, and resets the partial evaluation cache for v2