authorization

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package authorization defines protocol-neutral authorization contracts: a Request of principal, action and resource entities plus context, an Authorizer that returns a Decision, and the PolicySource and EntitySource interfaces an implementation reads from. Package cedar provides the Cedar implementation.

The package does not import package authentication; callers map an authenticated principal to a request entity themselves.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidConfiguration reports invalid constructor options.
	ErrInvalidConfiguration = errors.New("authorization: invalid configuration")
	// ErrInvalidRequest reports a malformed or unbounded request.
	ErrInvalidRequest = errors.New("authorization: invalid request")
	// ErrSource reports that a policy or entity source failed.
	ErrSource = errors.New("authorization: source unavailable")
	// ErrInvalidSource reports policies or entities that are empty, oversized
	// or malformed.
	ErrInvalidSource = errors.New("authorization: invalid source")
)

Sentinel errors returned by authorizers. A non-nil error always means the request is not authorized.

Functions

This section is empty.

Types

type Authorizer

type Authorizer interface {
	Authorize(context.Context, Request) (Decision, error)
}

Authorizer evaluates an authorization request.

type Decision

type Decision struct {
	Allowed bool
	Reasons []string
	Errors  []string
}

Decision is a deterministic authorization result.

type Entity

type Entity struct {
	Type string
	ID   string
}

Entity identifies one Cedar principal, action, or resource.

type EntitySource

type EntitySource interface {
	Entities(context.Context, Request) ([]byte, error)
}

EntitySource supplies Cedar entity JSON for one request.

type PolicySource

type PolicySource interface {
	Policies(context.Context) ([]byte, error)
}

PolicySource supplies Cedar policy text.

type Request

type Request struct {
	Principal Entity
	Action    Entity
	Resource  Entity
	Context   map[string]any
}

Request contains only authorization inputs. It is independent of authentication.

Directories

Path Synopsis
Package cedar implements authorization.Authorizer with the Cedar policy language (github.com/cedar-policy/cedar-go).
Package cedar implements authorization.Authorizer with the Cedar policy language (github.com/cedar-policy/cedar-go).

Jump to

Keyboard shortcuts

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