Skip to content

feat(asb): authenticate the rpc server#1095

Merged
binarybaron merged 3 commits into
masterfrom
feat/asb-rpc-cookie-auth
Jun 10, 2026
Merged

feat(asb): authenticate the rpc server#1095
binarybaron merged 3 commits into
masterfrom
feat/asb-rpc-cookie-auth

Conversation

@binarybaron

Copy link
Copy Markdown

No description provided.

The ASB JSON-RPC server generates a random token on startup, writes it to
a .cookie file in the data directory, and requires it as an HTTP Bearer
token. asb-controller reads the cookie via --cookie and attaches the
header; a new `cookie` subcommand prints the token. The orchestrator
mounts the asb-data volume into the controller and passes --cookie.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cfa4668. Configure here.

Comment thread swap-controller/src/main.rs Outdated
Reuse the existing .cookie token when present so clients keep working
across ASB restarts; only generate a new token when the file is missing
or empty, and propagate genuine read errors.
Replace the cookie-file scheme with a hashed password: the ASB verifies
the presented Bearer password against a salt:hmac HMAC-SHA256 verifier read
from --rpc-auth-file (mandatory when the RPC server is enabled). asb-controller
prompts for the password on startup and verifies before granting access.
The orchestrator gains a gen-rpc-auth command to produce the keyfile and
mounts it into the asb container.
@binarybaron binarybaron changed the title feat(asb): authenticate the RPC server with a cookie token feat(asb): authenticate the rpc server Jun 10, 2026
Comment thread swap-asb/src/main.rs
// Start RPC server conditionally
let _rpc_server = if let (Some(host), Some(port)) = (rpc_bind_host, rpc_bind_port) {
let auth_file = rpc_auth_file.context(
"The JSON-RPC server requires authentication: pass --rpc-auth-file pointing at a `salt:hmac` verifier file",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

salt:hmac is too specific here

Comment thread swap-asb/src/main.rs
let auth_file = rpc_auth_file.context(
"The JSON-RPC server requires authentication: pass --rpc-auth-file pointing at a `salt:hmac` verifier file",
)?;
let auth_verifier = std::fs::read_to_string(&auth_file)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extact this into a function (together with the sanity check below)

Comment thread swap-env/src/rpc_auth.rs
format!("{salt}:{hmac}")
}

/// Constant-time check of a password against a `<salt>:<hmac>` verifier.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont say its constant time

@binarybaron binarybaron merged commit d449317 into master Jun 10, 2026
64 of 76 checks passed
binarybaron added a commit that referenced this pull request Jun 10, 2026
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