GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: log tailnet tunnels to the connection log by cdigiamo-ant · Pull Request #27005 · coder/coder

Conversation

@cdigiamo-ant

@cdigiamo-ant cdigiamo-ant commented Jul 6, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Closes #27006.

Summary

Today the connection log has no user attribution for SSH / IDE sessions. The
agent reports ssh / vscode / jetbrains / reconnecting_pty rows, but by
the time the connection reaches the agent the Coder user identity is gone — see
the comment in coderd/agentapi/connectionlog.go:

// It's not possible to tell which user connected. Once we have the // capability, this may be reported by the agent.

As a result connection_logs.user_id is always NULL for those rows, and there
is no way to answer "which Coder user opened an SSH session into workspace X"
from the connection log alone. For enterprise audit use-cases (cross-user
workspace access, long-lived-token misuse) that's a significant gap.

Every such session is carried over a tailnet tunnel that the client opens via
GET /api/v2/workspaceagents/{id}/coordinate. That request is made with the
user's API key, so coderd does know who is connecting at that moment.

This PR adds a new connection_type value tailnet and writes one connection
log row from workspaceAgentClientCoordinate each time a client successfully
upgrades the coordinate WebSocket. The row carries:

  • user_id — from httpmw.APIKeyOptional(r)
  • ip / user_agent — from the HTTP request (real client IP once
    CODER_PROXY_TRUSTED_* is configured)
  • workspace_id / agent_name — the tunnel target

The event is treated like the other coderd-originated connection types
(workspace_app, port_forwarding): it's a point-in-time authorization event
with no disconnect_time, so it's excluded from the status: filter and
rendered via WebInfo (which already surfaces the connecting user in the
dashboard).

Why not fill user_id on the existing SSH rows?

Those rows are emitted by the agent over ReportConnection, which doesn't have
access to the Coder user or API key (the comment above is still accurate).
Plumbing identity down to the agent would be a protocol change; this approach
gets the same attribution without touching the agent API.

What about /api/v2/tailnet (Coder Desktop)?

tailnetRPCConn is user-scoped rather than workspace-scoped, so it doesn't
have a single target workspace to log against. It already reports
UserTailnetConnection telemetry. I've left it out of this PR to keep the
change small; happy to follow up if there's interest in logging it too.

Notes

  • Volume: this fires once per client tunnel (not per SSH exec), so it's the
    same order of magnitude as coordinator handshakes — typically far below the
    workspace-app rate.
  • Requests that arrive via workspace-proxy auth (no API key on the route) are
    skipped.
  • api_key_id isn't recorded because connection_logs has no column for it;
    user_id + user_agent + ip is what the existing web types store too.
    I'd like to add an api_key_id column in a follow-up (or here, if preferred)
    so these rows — and potentially workspace_app / port_forwarding rows —
    can also record which key was used; it's available at both write sites.
  • This fires for every DialAgent caller (coder ssh, coder port-forward,
    the VS Code extension, coder ping, coder speedtest, etc.), so a tailnet
    row means "user opened a tunnel to this agent", not "user ran SSH". There is
    currently no debounce on reconnect; if volume turns out to be a concern the
    same workspace_app_audit_sessions pattern could be applied here.
  • Happy to rename tailnet → tunnel (or similar) if that reads better.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions

github-actions Bot commented Jul 6, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the community Pull Requests and issues created by the community. label Jul 6, 2026
@github-actions github-actions Bot assigned cdigiamo-ant Jul 6, 2026
@cdigiamo-ant
cdigiamo-ant marked this pull request as draft July 6, 2026 16:31
@cdigiamo-ant
feat(coderd): log tailnet tunnels to the connection log
44f36a3
Agent-reported SSH/VSCode/JetBrains connection_log rows have no user_id
because the agent does not know which Coder user connected (see the
comment in coderd/agentapi/connectionlog.go). This makes it impossible
to attribute SSH/IDE sessions to a Coder user from the connection log.

Every such session is carried over a tailnet tunnel that the client
opens via /api/v2/workspaceagents/{id}/coordinate using the user's API
key, so coderd knows the user at that point.

Add a new connection_type 'tailnet' and write one connection_log row
from workspaceAgentClientCoordinate whenever an authenticated user
successfully upgrades the coordinate WebSocket. The row carries
user_id, ip, user_agent, workspace_id and agent_name, and is rendered
via WebInfo alongside workspace_app / port_forwarding.
@cdigiamo-ant cdigiamo-ant mentioned this pull request Jul 6, 2026
Connection log: attribute SSH/IDE sessions to the Coder user #27006
Closed
@cdigiamo-ant
cdigiamo-ant force-pushed the cdigiamo/connection-log-tailnet-type branch from 5527069 to 44f36a3 Compare July 6, 2026 17:01
@cdigiamo-ant
cdigiamo-ant marked this pull request as ready for review July 6, 2026 17:01
@cdigiamo-ant cdigiamo-ant changed the title feat(coderd): log tailnet tunnels to the connection log feat: log tailnet tunnels to the connection log Jul 6, 2026
@cdigiamo-ant

cdigiamo-ant commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cdrci2 added a commit to coder/cla that referenced this pull request Jul 6, 2026
@cdrci2
@cdigiamo-ant has signed the CLA in coder/coder#27005
b07f2ef
@github-actions github-actions Bot added the stale This issue is like stale bread. label Jul 19, 2026
@sreya sreya removed the stale This issue is like stale bread. label Jul 21, 2026
@sreya sreya mentioned this pull request Jul 28, 2026
feat: log tailnet tunnels to the connection log #27423
Merged
@github-actions github-actions Bot added the stale This issue is like stale bread. label Jul 29, 2026
@github-actions github-actions Bot closed this Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@cdigiamo-ant cdigiamo-ant

Labels

community Pull Requests and issues created by the community. stale This issue is like stale bread.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Connection log: attribute SSH/IDE sessions to the Coder user

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@cdigiamo-ant @sreya
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.