Documentation ¶
Index ¶
- type Oso
- func (o Oso) ClearRules() error
- func (o Oso) IsAllowed(actor interface{}, action interface{}, resource interface{}) (bool, error)
- func (o Oso) LoadFile(f string) error
- func (o Oso) LoadString(s string) error
- func (o Oso) NewQueryFromRule(name string, args ...interface{}) (*Query, error)
- func (o Oso) NewQueryFromStr(q string) (*Query, error)
- func (o Oso) QueryRule(name string, args ...interface{}) (<-chan map[string]interface{}, <-chan error)
- func (o Oso) QueryStr(q string) (<-chan map[string]interface{}, <-chan error)
- func (o Oso) RegisterClass(cls reflect.Type, cptr interface{}) error
- func (o Oso) RegisterClassWithName(cls reflect.Type, cptr interface{}, name string) error
- func (o Oso) RegisterConstant(value interface{}, name string) error
- func (o Oso) Repl() error
- type Polar
- type Query
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Oso ¶
type Oso struct {
// contains filtered or unexported fields
}
The central object to manage policy state and verify requests.
func NewOso ¶
Construct a new Oso instance.
import oso "github.com/osohq/go-oso" if o, err := oso.NewOso(); err != nil { t.Fatalf("Failed to set up Oso: %v", err) }
func (Oso) ClearRules ¶
Clear all rules from the Oso knowledge base (i.e., remove all loaded policies).
func (Oso) IsAllowed ¶
Check if an (actor, action, resource) combination is allowed by the policy. Returns the result as a bool, or an error.
func (Oso) LoadFile ¶
Load Polar policy from a ".polar" file, checking that all inline queries succeed.
func (Oso) LoadString ¶
Load Polar policy from a string, checking that all inline queries succeed.
func (Oso) NewQueryFromRule ¶
Create policy query for a rule. Accepts the name of the rule to query, and a variadic list of rule arguments. Returns a new *Query, on which `Next()` can be called to get the next result, or an error.
func (Oso) NewQueryFromStr ¶
Create policy query from a query string. Accepts the string to query for. Returns a new *Query, on which `Next()` can be called to get the next result, or an error.
func (Oso) QueryRule ¶
func (o Oso) QueryRule(name string, args ...interface{}) (<-chan map[string]interface{}, <-chan error)
Query the policy for a rule; the query is run in a new Go routine. Accepts the name of the rule to query, and a variadic list of rule arguments. Returns a channel of resulting binding maps, and a channel for errors. As the query is evaluated, all resulting bindings will be written to the results channel, and any errors will be written to the error channel.
func (Oso) QueryStr ¶
Query the policy using a query string; the query is run in a new Go routine. Accepts the string to query for. Returns a channel of resulting binding maps, and a channel for errors. As the query is evaluated, all resulting bindings will be written to the results channel, and any errors will be written to the error channel.
func (Oso) RegisterClass ¶ added in v0.0.3
Register a Go type so that it can be referenced within Polar files. Accepts a constructor function, or nil if no constructor is required.
func (Oso) RegisterClassWithName ¶ added in v0.0.3
Register a Go type under a certain name/alias, so that it can be referenced within Polar files by that name. Accepts a constructor function, or nil if no constructor is required.
func (Oso) RegisterConstant ¶ added in v0.0.3
Register a Go value as a Polar constant variable called `name`.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Execute a Polar query through the FFI/event interface.
func (*Query) GetAllResults ¶ added in v0.0.3
Executes the query until all results have been returned, and returns results as a list of binding maps.