security

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package security defines protocol-neutral authentication and authorization capabilities for Tacklr servers. server.Protocol implementations translate their wire formats into Attempt and Operation values; this package never interprets ACP, JSON-RPC, or HTTP types.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAuthenticationRequired means no authenticated principal is available.
	ErrAuthenticationRequired = errors.New("authentication required")
	// ErrAuthenticationFailed means supplied credentials were rejected.
	ErrAuthenticationFailed = errors.New("authentication failed")
	// ErrAuthorizationDenied means the principal cannot perform an operation.
	ErrAuthorizationDenied = errors.New("authorization denied")
)

Functions

This section is empty.

Types

type Attempt

type Attempt struct {
	Scheme     string
	Credential Secret
	Binding    ChannelBinding
}

Attempt is the canonical input to a host Authenticator.

type Authenticator

type Authenticator interface {
	Authenticate(context.Context, Attempt) (Principal, error)
}

Authenticator verifies an authentication attempt supplied by a protocol or transport adapter.

type Authorizer

type Authorizer interface {
	Authorize(context.Context, Principal, Operation) error
}

Authorizer decides whether a principal can perform an operation.

type ChannelBinding

type ChannelBinding struct {
	Kind string
	ID   string
}

ChannelBinding identifies the logical channel on which authentication occurred. Values are transport-neutral and contain no credential material.

type Context

type Context struct {
	Principal Principal
	Binding   ChannelBinding
}

Context is the authenticated state propagated through server connections.

func (Context) Authenticated

func (c Context) Authenticated() bool

Authenticated reports whether this context contains a valid principal.

type Operation

type Operation struct {
	Action   string
	Resource string
}

Operation is a protocol-neutral authorization request.

type Principal

type Principal struct {
	Subject string
}

Principal is the stable, opaque identity returned by a host Authenticator. Subject must be stable across reconnects when durable sessions can be loaded.

func NewPrincipal

func NewPrincipal(subject string) (Principal, error)

NewPrincipal constructs a Principal and rejects an empty subject.

func (Principal) Valid

func (p Principal) Valid() bool

Valid reports whether the principal has a stable subject.

type Secret

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

Secret is ephemeral credential material. Its String and GoString methods are deliberately redacted so ordinary structured logging cannot reveal it.

func NewSecret

func NewSecret(value []byte) Secret

NewSecret copies credential material into a redaction-safe value.

func (Secret) Bytes

func (s Secret) Bytes() []byte

Bytes returns a copy for a host Authenticator.

func (Secret) Empty

func (s Secret) Empty() bool

Empty reports whether no credential material is present.

func (Secret) GoString

func (Secret) GoString() string

func (Secret) String

func (Secret) String() string

type Service

type Service struct {
	Authenticator Authenticator
	Authorizer    Authorizer
}

Service coordinates host-provided authentication and authorization without knowing how any protocol represents credentials or errors.

func (*Service) Authenticate

func (s *Service) Authenticate(ctx context.Context, attempt Attempt) (Context, error)

Authenticate delegates to the host and validates its returned invariant.

func (*Service) Authorize

func (s *Service) Authorize(ctx context.Context, securityContext Context, operation Operation) error

Authorize requires an authenticated principal and delegates to the optional host policy. No Authorizer means every authenticated principal is allowed.

Jump to

Keyboard shortcuts

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