clcedard

package
v0.26.6 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package clcedard provides components for the cedard authorization service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Provide

func Provide() fx.Option

Provide dependencies.

Types

type Client

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

Client implements a client for the cedard authorization service.

func NewClient

func NewClient(cfg Config, logs *zap.Logger, htcl *http.Client) *Client

NewClient inits the client.

func (*Client) Authorize

func (c *Client) Authorize(ctx context.Context, in *Input) (out *Output, err error)

Authorize asks the cedard service authorizes the given input.

func (*Client) IsAuthorized

func (c *Client) IsAuthorized(ctx context.Context, in *Input) (bool, error)

IsAuthorized returns true the authorization returned an Allow decision without errors. Otherwise, it returns false.

type Config

type Config struct {
	// BaseURL configures the base url of the cedard service.
	BaseURL string `env:"BASE_URL" envDefault:"https://authz.crewlinker.com"`
	// JWTSigningSecret configures the secret for signing JWTs.
	JWTSigningSecret string `env:"JWT_SIGNING_SECRET" envDefault:"some-secret-for-testing"`
	// BackoffMaxElapsedTime configures the max elapsed time for the retry mechanism.
	BackoffMaxElapsedTime time.Duration `env:"BACKOFF_MAX_ELAPSED_TIME" envDefault:"3s"`
}

Config configures the package.

type Input

type Input struct {
	Principal string         `json:"principal"`
	Action    string         `json:"action"`
	Resource  string         `json:"resource"`
	Policies  string         `json:"policies"`
	Context   map[string]any `json:"context"`
	Schema    map[string]any `json:"schema"`
	Entities  []any          `json:"entities"`
}

Input for authorzation.

type Output

type Output struct {
	Decision      string   `json:"decision"`
	PolicyIds     []string `json:"policy_ids"`
	ErrorMessages []string `json:"error_messages"`
}

Output from authorization.

Jump to

Keyboard shortcuts

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