v1

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: AGPL-3.0 Imports: 9 Imported by: 7

Documentation

Overview

Package v1 provides HTTP handlers that implement the ReBAC Admin OpenAPI spec. This package delegates authorization and data manipulation to user-defined "backend"s that implement the designated abstractions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithIdentity

func ContextWithIdentity(ctx context.Context, identity any) context.Context

ContextWithIdentity returns a new context from the given one and associates it with the given identity object. The identity can be retrieved by calling the `GetIdentityFromContext` with the context returned by this function.

Users of the library should not directly use this method, unless they need to handle the authentication outside of the library, in which case they need to call this function (with the authenticated identity) to get a new context and then pass it (as the HTTP request context) to the next HTTP handler.

func GetIdentityFromContext

func GetIdentityFromContext(ctx context.Context) (any, error)

GetIdentityFromContext fetches authenticated identity of the caller from the given request context. If the value was not found in the given context, this will return an error.

The function is intended to be used by service backends.

func NewAuthenticationError

func NewAuthenticationError(message string) error

NewAuthenticationError returns an error instance that represents an authentication error.

func NewAuthorizationError

func NewAuthorizationError(message string) error

NewAuthorizationError returns an error instance that represents an unauthorized access error.

func NewInvalidRequestError

func NewInvalidRequestError(message string) error

NewInvalidRequestError returns an error instance that represents a problem with the input (e.g., when trying to add an entry which already exists).

func NewMissingRequestBodyError

func NewMissingRequestBodyError(message string) error

NewMissingRequestBodyError returns an error instance that represents a missing request body error.

func NewNotFoundError

func NewNotFoundError(message string) error

NewNotFoundError returns an error instance that represents a not-found error.

func NewNotImplementedError

func NewNotImplementedError(message string) error

NewNotImplementedError returns an error instance that reports the requested operation is not implemented by the backend.

func NewRequestBodyValidationError

func NewRequestBodyValidationError(message string) error

NewRequestBodyValidationError returns an error instance that represents a request body validation error.

func NewUnknownError

func NewUnknownError(message string) error

NewUnknownError returns an error instance that represents an unknown internal error.

func NewValidationError

func NewValidationError(message string) error

NewValidationError returns an error instance that represents an input validation error.

Types

type ErrorResponseMapper

type ErrorResponseMapper interface {
	// MapError maps an error into a Response. If the method is unable to map the
	// error (e.g., the error is unknown), it must return nil.
	MapError(context.Context, error) *resources.Response
}

ErrorResponseMapper is the basic interface to allow for error -> http response mapping

type ReBACAdminBackend

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

ReBACAdminBackend represents the ReBAC admin backend as a whole package.

func NewReBACAdminBackend

func NewReBACAdminBackend(params ReBACAdminBackendParams) (*ReBACAdminBackend, error)

NewReBACAdminBackend returns a new ReBACAdminBackend instance, configured with given backends.

func (*ReBACAdminBackend) Handler

func (b *ReBACAdminBackend) Handler(baseURL string) http.Handler

Handler returns HTTP handlers implementing the ReBAC Admin OpenAPI spec.

type ReBACAdminBackendParams

type ReBACAdminBackendParams struct {
	Authenticator            interfaces.Authenticator
	AuthenticatorErrorMapper ErrorResponseMapper

	Identities            interfaces.IdentitiesService
	IdentitiesErrorMapper ErrorResponseMapper

	Roles            interfaces.RolesService
	RolesErrorMapper ErrorResponseMapper

	IdentityProviders            interfaces.IdentityProvidersService
	IdentityProvidersErrorMapper ErrorResponseMapper

	Capabilities            interfaces.CapabilitiesService
	CapabilitiesErrorMapper ErrorResponseMapper

	Entitlements            interfaces.EntitlementsService
	EntitlementsErrorMapper ErrorResponseMapper

	Groups            interfaces.GroupsService
	GroupsErrorMapper ErrorResponseMapper

	Resources            interfaces.ResourcesService
	ResourcesErrorMapper ErrorResponseMapper
}

ReBACAdminBackendParams contains references to user-defined implementation of required abstractions, called "backend"s.

Directories

Path Synopsis
Package resources provides primitives to interact with the openapi HTTP API.
Package resources provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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