feat(cli): add no-auth service support by chetan · Pull Request #57168 · anomalyco/opencode · GitHub
Skip to content

feat(cli): add no-auth service support - #57168

Open
chetan wants to merge 5 commits into
anomalyco:devfrom
chetan:service-no-auth
Open

chetan wants to merge 5 commits into
anomalyco:devfrom
chetan:service-no-auth

Conversation

@chetan

@chetan chetan commented Oct 19, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #43039.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This builds on #43069 to let the service run without authentication.

Add serve --no-auth, OPENCODE_AUTH=false, and service set auth false. Save the service setting across restarts. Authentication stays on by default.

Keep authentication on for private stdio servers. Reject service startup if remote access is on and authentication is off. Print a warning when authentication is off.

How did you verify your code works?

  • All 30 CLI service tests pass.
  • bun run check passes.
  • Local process checks confirm HTTP 200 without authentication and a warning.
  • A private stdio server returns HTTP 401 with OPENCODE_AUTH=false.
  • A service with remote access and authentication off fails before it starts the tunnel.

Screenshots / recordings

Not applicable. This change has no UI.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

thdxr and others added 4 commits October 19, 2026 10:48
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

opencode serve --no-auth, OPENCODE_AUTH=false and opencode service set auth false work as described. With the PR, serve --no-auth printed no password and /api/info returned 200. Plain serve still printed a password and returned 401. The server and CLI service tests pass (4 and 30), and both packages type-check.

Public API (all additions, backwards compatible because auth stays on by default):

  • the --no-auth flag on opencode serve
  • the OPENCODE_AUTH environment variable (boolean, default true)
  • the auth key in the managed service config, settable with opencode service get/set/unset auth
  • in the service registration file, password is now omitted when auth is off; clients that read it must treat a missing password as "no auth", which Service.discover already does
  • ServerProcess.start in @opencode/server no longer fails when password is missing or empty; it now serves without auth instead

Concerns:

  • When auth is off and remote access is on, the tunnel is open without a password (see inline).
  • Nothing is printed when auth is disabled, even when the server listens on a non-loopback hostname (see inline).
  • OPENCODE_AUTH=false is read as a process-wide default, so it also turns off auth for the private stdio servers the TUI starts. Consider limiting it to default and service modes.

Fixes #43039
Related: #49452, #51724

Comment thread packages/cli/src/server-process.ts Outdated
yield* RetainedImage.retain(global.cache, "service")
const { start } = yield* Effect.promise(() => import("@opencode/server/process"))
const environmentPassword = yield* Env.password
const auth = !options.noAuth && (config.auth ?? (yield* Env.auth))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When auth is false and config.remote is set, the service still starts RemoteTunnel.run (around line 190), so the server becomes reachable from the internet with no password. The only protection left is the route subdomain. The consent text in pair.ts (remoteWarning) also still says "access requires your server password". Please either refuse to start the tunnel when auth is disabled, or refuse service set auth false and pair --remote while the other is on.

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.

Fixed in 62b62a4. Service startup now fails if remote access is on and authentication is off. A local process check confirmed that it fails before the tunnel starts.

@@ -204,7 +206,7 @@ const processEffect = Effect.fnUntraced(function* (options: Options) {
}
const url = HttpServer.formatAddress(server.address)
console.log(options.mode === "stdio" ? JSON.stringify({ url }) : `server listening on ${url}`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nothing tells the user that auth is off. Running --no-auth --hostname 0.0.0.0, or a service config with hostname: 0.0.0.0 and auth: false, exposes the server (shell and filesystem tools) to the network without a word. Please log a clear warning when password is undefined, at least when the address is not loopback.

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.

Fixed in 62b62a4. The server now prints a warning whenever authentication is off. A local process check confirmed the warning and HTTP 200 without credentials. Private stdio servers also keep authentication on when OPENCODE_AUTH=false; verified with HTTP 401.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This branch has not been deployed

No deployments
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.

[FEATURE]:[v2] add no password flag for "opencode2 serve"

2 participants