gatewayauth

package module
v0.0.0-...-cbee766 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package gatewayauth authenticates requests addressed to a specific MooX node.

Index

Constants

View Source
const Version = "moox-gateway-auth-v1"

Variables

This section is empty.

Functions

func NewTRPCClientFilter

func NewTRPCClientFilter(credentials Credentials, targetNode string, now func() time.Time) filter.ClientFilter

NewTRPCClientFilter signs the serialized request body before it crosses the native Node Service Gateway. The generated Storage clients remain unchanged; only their target and this filter are supplied by the caller.

func NewTRPCClientOptions

func NewTRPCClientOptions(target, targetNode string, credentials Credentials) []client.Option

NewTRPCClientOptions returns the common target, protocol, and HMAC options for a generated client that must use the native Node Service Gateway.

func ReadSigningSecret

func ReadSigningSecret(path string) (string, error)

ReadSigningSecret loads a bounded private signing key without following symlinks.

func Sign

func Sign(c Credentials, req Request, now time.Time) (http.Header, error)

func ValidateTargetNode

func ValidateTargetNode(value string) error

ValidateTargetNode applies the same target validation used by signing, so services can reject unusable gateway configuration before opening resources.

Types

type Claims

type Claims struct {
	KeyID, Caller, Nonce, TargetNode string
	Timestamp                        int64
	TTL                              time.Duration
}

func Verify

func Verify(c Credentials, req Request, header http.Header, now time.Time) (Claims, error)

type CredentialRegistry

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

func LoadCredentialRegistry

func LoadCredentialRegistry(path string) (*CredentialRegistry, error)

func NewCredentialRegistry

func NewCredentialRegistry(credentials []Credentials) (*CredentialRegistry, error)

NewCredentialRegistry indexes by KeyID. A caller may have both its current and retiring key during a controlled rotation; KeyIDs are globally unique.

func (*CredentialRegistry) Verify

func (registry *CredentialRegistry) Verify(req Request, header http.Header, now time.Time) (Claims, error)

type Credentials

type Credentials struct {
	KeyID, Caller, Secret string
	Expire, ClockSkew     time.Duration
}

func CredentialsFromKeyFile

func CredentialsFromKeyFile(keyID, path string) (Credentials, error)

CredentialsFromKeyFile loads a service secret without accepting symlinks or group/world-readable files. The gateway and every native tRPC client use the same fail-closed file contract.

type Request

type Request struct {
	Method, Path, TargetNode string
	Caller, Callee, Func     string
	Body                     []byte
}

Directories

Path Synopsis
Package nativewire installs the process-wide tRPC frame ceiling before any client or listener starts.
Package nativewire installs the process-wide tRPC frame ceiling before any client or listener starts.

Jump to

Keyboard shortcuts

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