Documentation
¶
Overview ¶
OAuth/OIDC authentication — you're a Neo admin or you're not. No roles, no permissions matrix, no junior accounts. SSO proves you're on the team. That's the only gate.
Package security implements agent-to-agent trust via ECDSA identity and ephemeral ECDH session encryption.
Each Neo has an ECDSA P-256 key pair. The private key never leaves the machine. The public key IS the identity. Gossip messages are signed. Sessions are encrypted with ECDH-derived ephemeral keys. Swarm secret rotates via gossip. Workers that miss rotation prove identity and get re-keyed automatically.
Secrets rotation tracking — monitors secret age and alerts when rotation is due. Integrates with Vault enricher and the knowledge graph.
Index ¶
- func DeleteToken() error
- func GenerateSwarmSecret() ([]byte, error)
- func MarshalPublicKey(pub *ecdsa.PublicKey) string
- func PublicEndpoint(next http.HandlerFunc) http.HandlerFunc
- func RequireAPIKey(keys map[string]string, next http.HandlerFunc) http.HandlerFunc
- func SaveToken(token *Token) error
- func UnmarshalPublicKey(b64 string) (*ecdsa.PublicKey, error)
- func VerifySignature(pubKey *ecdsa.PublicKey, data, signature []byte) bool
- type AuditEntry
- type AuditLogger
- type Auth
- type AuthConfig
- type Identity
- type Keyring
- func (k *Keyring) Count() int
- func (k *Keyring) GetKey(pubB64 string) *ecdsa.PublicKey
- func (k *Keyring) IsTrusted(pubB64 string) bool
- func (k *Keyring) List() []TrustedKey
- func (k *Keyring) Revoke(pubB64 string)
- func (k *Keyring) Trust(pubB64, workerID, trustedBy string) error
- func (k *Keyring) Verify(pubB64 string, data, signature []byte) string
- type Middleware
- type RotationTracker
- type SecretInfo
- type Session
- type SwarmSecret
- func (s *SwarmSecret) ApplyRotation(newSecret []byte) error
- func (s *SwarmSecret) Decrypt(msg []byte) ([]byte, error)
- func (s *SwarmSecret) Encrypt(plaintext []byte) ([]byte, error)
- func (s *SwarmSecret) Rotate() (newSecretEncrypted []byte, newSecretRaw []byte, err error)
- func (s *SwarmSecret) Version() uint64
- type Token
- type TrustedKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSwarmSecret ¶
GenerateSwarmSecret creates a random 256-bit swarm secret.
func MarshalPublicKey ¶
MarshalPublicKey encodes a public key to base64 for transport.
func PublicEndpoint ¶
func PublicEndpoint(next http.HandlerFunc) http.HandlerFunc
PublicEndpoint wraps a handler with no auth (health checks, etc).
func RequireAPIKey ¶
func RequireAPIKey(keys map[string]string, next http.HandlerFunc) http.HandlerFunc
RequireAPIKey wraps a handler that requires an API key (for external clients).
func UnmarshalPublicKey ¶
UnmarshalPublicKey decodes a base64 public key.
Types ¶
type AuditEntry ¶
type AuditEntry struct {
Timestamp time.Time `json:"timestamp"`
User string `json:"user"`
Role string `json:"role"`
Action string `json:"action"`
Target string `json:"target"`
SourceIP string `json:"source_ip"`
}
AuditLog records an authenticated action.
type AuditLogger ¶
type AuditLogger struct {
// contains filtered or unexported fields
}
AuditLogger records actions for compliance.
func NewAuditLogger ¶
func NewAuditLogger() *AuditLogger
func (*AuditLogger) Log ¶
func (a *AuditLogger) Log(user, role, action, target, sourceIP string)
func (*AuditLogger) Recent ¶
func (a *AuditLogger) Recent(limit int) []AuditEntry
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth handles OAuth/OIDC authentication.
func (*Auth) ExchangeCode ¶
ExchangeCode trades an OAuth code for a token.
func (*Auth) RequireAuth ¶
func (a *Auth) RequireAuth(next http.HandlerFunc) http.HandlerFunc
RequireAuth wraps an HTTP handler with OAuth token validation. You're an admin or you get 401. No roles.
type AuthConfig ¶
type AuthConfig struct {
Enabled bool `yaml:"enabled"`
Provider string `yaml:"provider"` // oidc, google, github, okta, azure-ad
Issuer string `yaml:"issuer"` // OIDC issuer URL
ClientID string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"`
RedirectURL string `yaml:"redirect_url"`
AllowedEmails []string `yaml:"allowed_emails"` // explicit allowlist (empty = all from issuer)
AllowedDomain string `yaml:"allowed_domain"` // domain allowlist: "example.com"
}
AuthConfig holds OAuth/OIDC configuration.
type Identity ¶
type Identity struct {
PrivateKey *ecdsa.PrivateKey
PublicKey *ecdsa.PublicKey
PublicB64 string // base64-encoded public key for display/transport
}
Identity holds this Neo's ECDSA key pair.
func GenerateIdentity ¶
GenerateIdentity creates a new ECDSA P-256 key pair.
func LoadOrCreateIdentity ¶
LoadOrCreateIdentity loads identity from disk, or generates a new one.
type Keyring ¶
type Keyring struct {
// contains filtered or unexported fields
}
Keyring holds trusted public keys. Backed by shared database in enterprise, in-memory for workstation mode.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware wraps HTTP handlers with security checks.
func NewMiddleware ¶
func NewMiddleware(keyring *Keyring, swarm *SwarmSecret) *Middleware
NewMiddleware creates a security middleware.
func (*Middleware) RequireSwarmAuth ¶
func (m *Middleware) RequireSwarmAuth(next http.HandlerFunc) http.HandlerFunc
RequireSwarmAuth wraps a handler that requires authenticated Neo-to-Neo communication. Checks: X-Neo-PublicKey header present, X-Neo-Signature verifies, key is trusted.
type RotationTracker ¶
type RotationTracker struct {
// contains filtered or unexported fields
}
RotationTracker monitors all known secrets for rotation compliance.
func NewRotationTracker ¶
func NewRotationTracker() *RotationTracker
NewRotationTracker creates a tracker.
func (*RotationTracker) Add ¶
func (t *RotationTracker) Add(s SecretInfo)
Add registers a secret for tracking.
func (*RotationTracker) Format ¶
func (t *RotationTracker) Format() string
Format produces a human-readable rotation report.
func (*RotationTracker) NeedingRotation ¶
func (t *RotationTracker) NeedingRotation() []SecretInfo
NeedingRotation returns all secrets that need rotation.
type SecretInfo ¶
type SecretInfo struct {
Name string `json:"name"`
Service string `json:"service"`
Type string `json:"type"` // api_key, password, certificate, ssh_key, token
Source string `json:"source"` // vault, env, config, manual
CreatedAt time.Time `json:"created_at"`
RotatedAt time.Time `json:"rotated_at"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
MaxAgeDays int `json:"max_age_days"` // policy: rotate after N days
}
SecretInfo tracks a secret's lifecycle.
func (*SecretInfo) AgeDays ¶
func (s *SecretInfo) AgeDays() int
AgeDays returns how many days since last rotation.
func (*SecretInfo) DaysUntilExpiry ¶
func (s *SecretInfo) DaysUntilExpiry() int
DaysUntilExpiry returns days until the secret expires (-1 if no expiry).
func (*SecretInfo) NeedsRotation ¶
func (s *SecretInfo) NeedsRotation() bool
NeedsRotation returns true if the secret exceeds max age or is near expiry.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is an ephemeral encrypted channel between two Neos. Derived via ECDH from both parties' ECDSA keys. Lives in memory only — never persisted, never reused.
func NewSession ¶
NewSession creates an ephemeral encrypted session with a peer. Uses ECDH: my private key + their public key → shared secret → AES-256-GCM key.
type SwarmSecret ¶
type SwarmSecret struct {
// contains filtered or unexported fields
}
SwarmSecret handles swarm-wide encryption for gossip messages. Rotates via gossip propagation — FIFO, no grace window.
func NewSwarmSecret ¶
func NewSwarmSecret(secret []byte) (*SwarmSecret, error)
NewSwarmSecret creates a swarm secret from the initial key (from registration).
func (*SwarmSecret) ApplyRotation ¶
func (s *SwarmSecret) ApplyRotation(newSecret []byte) error
ApplyRotation switches to a new swarm secret. FIFO — immediate, no grace window.
func (*SwarmSecret) Decrypt ¶
func (s *SwarmSecret) Decrypt(msg []byte) ([]byte, error)
Decrypt decrypts a gossip message. Rejects stale timestamps (>60s drift).
func (*SwarmSecret) Encrypt ¶
func (s *SwarmSecret) Encrypt(plaintext []byte) ([]byte, error)
Encrypt encrypts a gossip message with the swarm secret. Format: [12 nonce][N ciphertext+tag][8 timestamp][8 version]
func (*SwarmSecret) Rotate ¶
func (s *SwarmSecret) Rotate() (newSecretEncrypted []byte, newSecretRaw []byte, err error)
Rotate generates a new swarm secret and returns the encrypted rotation message. The new secret is encrypted with the OLD secret so only current swarm members can read it.
func (*SwarmSecret) Version ¶
func (s *SwarmSecret) Version() uint64
Version returns the current secret version.