api

package
v0.0.0-...-af2e488 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 23 Imported by: 2

Documentation

Overview

Package api declares Datly 1.0 components that are the authz SDK endpoints.

Index

Constants

View Source
const Capability = xhandler.ValueKey("authz.sdk")
View Source
const Package = "github.com/viant/authz/component/api"

Variables

View Source
var Datly = new(Components)

Functions

func LinkedRegistrations

func LinkedRegistrations(services *Services, codecs xcodec.Factory) ([]*registry.RegisteredComponent, error)

LinkedRegistrations builds the same SDK routes from the linked component holder. Embedding binaries can mount authz without shipping this module's Go source tree. The holder's typed fields and tags remain the route authority.

func Registrations

func Registrations(ctx context.Context, baseDir string, services *Services, codecs xcodec.Factory) ([]*registry.RegisteredComponent, error)

Registrations discovers the declared SDK components using native Datly bootstrap. The host supplies its verifier and narrow authz capabilities. Other projects can use these same components in their own runtime.

Types

type CatalogAdmission

type CatalogAdmission func(context.Context, gating.Principal, CatalogEntry) (handled bool, allowed bool, err error)

CatalogAdmission may handle a host-owned entry whose authority is not a standalone ACL document (for example an inherited logical resource). Unhandled entries keep the ordinary shared viewAccess policy check.

type CatalogEntry

type CatalogEntry struct {
	Name        string         `json:"name"`
	Resource    authz.Resource `json:"resource"`
	Actions     []string       `json:"actions"`
	GateActions []string       `json:"gateActions,omitempty"`
	// Target is an optional server-authored selection hint for a host editor.
	// It conveys no identity or allow decision; the target service reauthorizes.
	Target map[string]string `json:"target,omitempty"`
	// Context is supplied by the trusted catalog provider for an optional
	// host admission check. It is never serialized to HTTP/MCP clients.
	Context any `json:"-"`
}

CatalogEntry is a host-authored resource and action choice. The SDK checks viewAccess before returning it; the entry itself is never a grant.

func ListAuthorizedCatalog

func ListAuthorizedCatalog(ctx context.Context, services *Services) ([]CatalogEntry, error)

ListAuthorizedCatalog applies one verified principal and exact policy revisions to a trusted host inventory. Hosts may reuse it for their local editor route and MCP SDK so both surfaces expose identical choices.

type CatalogFunc

type CatalogFunc func(context.Context) ([]CatalogEntry, error)

func (CatalogFunc) List

func (f CatalogFunc) List(ctx context.Context) ([]CatalogEntry, error)

type CatalogInput

type CatalogInput struct {
	JWT *jwt.Claims `parameter:"JWT,kind=header,in=Authorization,dataType=string" codec:"JwtClaim" json:"-"`
}

type CatalogOutput

type CatalogOutput struct {
	Resources []CatalogEntry `json:"resources"`
}

type CatalogProvider

type CatalogProvider interface {
	List(context.Context) ([]CatalogEntry, error)
}

type CheckInput

type CheckInput struct {
	JWT       *jwt.Claims     `parameter:"JWT,kind=header,in=Authorization,dataType=string" codec:"JwtClaim" json:"-"`
	Resource  authz.Resource  `parameter:"Resource,kind=body,in=resource,required=true" json:"resource"`
	Action    string          `parameter:"Action,kind=body,in=action,required=true" json:"action"`
	Selection *[]authz.Entity `parameter:"Selection,kind=body,in=selection" json:"selection,omitempty"`
}

type Components

type Components struct {
	Catalog     xdatly.Component[CatalogInput, CatalogOutput]        `` /* 151-byte string literal not displayed */
	Check       xdatly.Component[CheckInput, DecisionOutput]         `` /* 156-byte string literal not displayed */
	Get         xdatly.Component[PolicyInput, PolicyOutput]          `` /* 145-byte string literal not displayed */
	Context     xdatly.Component[PolicyInput, PolicyContextOutput]   `` /* 167-byte string literal not displayed */
	Create      xdatly.Component[WriteInput, PolicyOutput]           `` /* 157-byte string literal not displayed */
	Replace     xdatly.Component[WriteInput, PolicyOutput]           `` /* 161-byte string literal not displayed */
	GateCheck   xdatly.Component[GateCheckInput, GateDecisionOutput] `` /* 149-byte string literal not displayed */
	GateGet     xdatly.Component[GateInput, GateDocumentOutput]      `` /* 141-byte string literal not displayed */
	GateContext xdatly.Component[GateInput, GateContextOutput]       `` /* 157-byte string literal not displayed */
	GateReplace xdatly.Component[GateWriteInput, GateDocumentOutput] `` /* 157-byte string literal not displayed */
}

func (Components) DatlyHandler

func (Components) DatlyHandler(name string) func() (rhandler.TypedHandler, error)

type DecisionOutput

type DecisionOutput struct {
	Decision authz.Decision `json:"decision"`
}

type GateCheckInput

type GateCheckInput struct {
	JWT      *jwt.Claims    `parameter:"JWT,kind=header,in=Authorization,dataType=string" codec:"JwtClaim" json:"-"`
	Resource authz.Resource `parameter:"Resource,kind=body,in=resource,required=true" json:"resource"`
	Action   string         `parameter:"Action,kind=body,in=action,required=true" json:"action"`
	Selected []authz.Entity `parameter:"Selected,kind=body,in=selected" json:"selected,omitempty"`
}

type GateContextOutput

type GateContextOutput struct {
	Context gating.EditorContext `json:"context"`
}

type GateDecisionOutput

type GateDecisionOutput struct {
	Decision gating.Decision `json:"decision"`
}

type GateDocumentOutput

type GateDocumentOutput struct {
	Document gating.RequirementsDocument `json:"document"`
}

type GateInput

type GateInput struct {
	JWT      *jwt.Claims    `parameter:"JWT,kind=header,in=Authorization,dataType=string" codec:"JwtClaim" json:"-"`
	Resource authz.Resource `parameter:"Resource,kind=body,in=resource,required=true" json:"resource"`
	Action   string         `parameter:"Action,kind=body,in=action,required=true" json:"action"`
}

type GateWriteInput

type GateWriteInput struct {
	JWT              *jwt.Claims         `parameter:"JWT,kind=header,in=Authorization,dataType=string" codec:"JwtClaim" json:"-"`
	Resource         authz.Resource      `parameter:"Resource,kind=body,in=resource,required=true" json:"resource"`
	Action           string              `parameter:"Action,kind=body,in=action,required=true" json:"action"`
	ExpectedRevision string              `parameter:"ExpectedRevision,kind=body,in=expectedRevision,required=true" json:"expectedRevision"`
	Requirements     gating.Requirements `parameter:"Requirements,kind=body,in=requirements,required=true" json:"requirements"`
}

type PolicyContextOutput

type PolicyContextOutput struct {
	Context authz.EditorContext `json:"context"`
}

type PolicyInput

type PolicyInput struct {
	JWT      *jwt.Claims    `parameter:"JWT,kind=header,in=Authorization,dataType=string" codec:"JwtClaim" json:"-"`
	Resource authz.Resource `parameter:"Resource,kind=body,in=resource,required=true" json:"resource"`
}

type PolicyOutput

type PolicyOutput struct {
	Document authz.Document `json:"document"`
}

type Services

type Services struct {
	Authorization    *authz.Service
	Policies         *authz.Administration
	Gates            *gating.Evaluator
	Requirements     *gating.Administration
	Catalog          CatalogProvider
	CatalogAdmission CatalogAdmission
}

type WriteInput

type WriteInput struct {
	JWT      *jwt.Claims    `parameter:"JWT,kind=header,in=Authorization,dataType=string" codec:"JwtClaim" json:"-"`
	Document authz.Document `parameter:"Document,kind=body,in=document,required=true" json:"document"`
}

Jump to

Keyboard shortcuts

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