Skip to content

feat: add NKey auth to local NATS server (#35) - #40

Merged
mfethe1 merged 1 commit into
sandcastle/openclaw-memory-prd-basefrom
sandcastle/issue-35-feat-add-nkey-auth-to-local-nats-server
May 6, 2026
Merged

mfethe1 merged 1 commit into
sandcastle/openclaw-memory-prd-basefrom
sandcastle/issue-35-feat-add-nkey-auth-to-local-nats-server

Conversation

@mfethe1

@mfethe1 mfethe1 commented May 6, 2026

Copy link
Copy Markdown
Owner

Closes #35

Changes

  • infra/local-nats/gen-nkeys.sh — NKey pair generator; --write patches conf + .env in-place
  • infra/local-nats/nats-server.conf — authorization block with placeholder key (inactive until gen-nkeys.sh --write is run on mack)
  • memu/cluster.py — _build_auth_opts(node) extracted; LOCAL node uses NATS_LOCAL_NKEY_SEED first
  • memu/nats_config.py — resolve_local_nkey_seed() helper
  • tests/test_nats_local_nkey_auth.py — 15 tests; 469 total passing

Activate on mack

bash infra/local-nats/gen-nkeys.sh --write
brew services restart nats-server
manage_memu.sh restart

🤖 Sandcastle agent

Wire NATS_LOCAL_NKEY_SEED as the Ed25519 credential for the single-host
NATS instance so unauthenticated clients are refused while leaving the
Railway/NGS credential chain (NATS_NKEY_SEED / NATS_CREDS_FILE) intact.

- infra/local-nats/nats-server.conf: add authorization block with nkey
  user entry (placeholder public key; replace after running gen-nkeys.sh)
- infra/local-nats/gen-nkeys.sh: keygen script — generates a user NKey
  pair and optionally patches the conf + .env in-place (--write flag)
- .env.example: document NATS_LOCAL_NKEY_SEED alongside existing NATS
  auth vars with clear separation between local and Railway credentials
- memu/cluster.py: extract _build_auth_opts(node) so LOCAL uses
  NATS_LOCAL_NKEY_SEED first; Railway node ignores it
- memu/nats_config.py: add resolve_local_nkey_seed() helper
- tests/test_nats_local_nkey_auth.py: 15 unit tests covering isolation,
  priority order, fallbacks, and conf-file shape

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mfethe1
mfethe1 merged commit 28ebe7b into sandcastle/openclaw-memory-prd-base May 6, 2026
1 of 2 checks passed
@mfethe1
mfethe1 deleted the sandcastle/issue-35-feat-add-nkey-auth-to-local-nats-server branch May 6, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant