sdk

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action added in v0.1.2

type Action string

type CheckRequest

type CheckRequest struct {
	// Principal is typically the user.
	Principal Principal `json:"principal"`
	// Action is the verb (e.g., read, write, update, view, list)
	Action Action `json:"action"`
	// Resource is the thing being accessed.
	Resource Resource `json:"resource"`
}

CheckRequest - Provides a principal, action, and resource for Cedar Agent to evaluate an authorization decision.

type Client

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

Client - A client for interacting with Cedar Agent.

func NewClient

func NewClient(c *http.Client, opts ...Option) *Client

NewClient - Creates a new client for interacting with Cedar Agent.

func (Client) Check

func (c Client) Check(_ context.Context, payload CheckRequest) (*Decision, error)

Check - Performs an authorization request using Cedar Agent.

func (Client) CheckBatch

func (c Client) CheckBatch(
	ctx context.Context,
	principal Principal,
	reqs map[Action][]Resource,

	numWorkers int,
) (map[CheckRequest]Decision, error)

CheckBatch - Performs a batch of authorization requests using Cedar Agent.

type Decision added in v0.1.2

type Decision struct {
	// Allowed - Whether the principal is allowed to perform the action on the
	// resource.
	Allowed bool
	// Diagnostics - Insight into how the decision was reached.
	Diagnostics Diagnostics
}

Decision - An authorization decision.

type Diagnostics added in v0.1.2

type Diagnostics struct {
	// Errors that occurred during the evaluation decisions.
	Errors []interface{} `json:"errors"`
	// Reason that the decision was made (e.g., policies involved).
	Reason []string `json:"reason"`
}

Diagnostics - Sheds light into the evaluation decision.

type IsAuthorizedResponse added in v0.1.2

type IsAuthorizedResponse struct {
	// Decision - Whether the principal is allowed to perform the action on the
	// resource.
	Decision string `json:"decision"`
	// Diagnostics - Insight into how the decision was reached.
	Diagnostics Diagnostics `json:"diagnostics"`
}

IsAuthorizedResponse - HTTP Response from Cedar Agent.

type Option

type Option func(*config)

Option - A functional option for configuring your Cedar Agent client.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL - Configures Cedar Agent's base URL. By default, we assume it runs on http://localhost:8180.

func WithParallelizationFactor

func WithParallelizationFactor(numWorkers int) Option

WithParallelizationFactor - Configures the client's parallelization factor when performing a batch of authorization requests in parallel.

type Principal added in v0.1.2

type Principal string

type Resource added in v0.1.2

type Resource string

Jump to

Keyboard shortcuts

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