Skip to content

feat: list an Octopus server's spaces for a connection with a stored API key - #262

Merged
matt-richardson merged 8 commits into
mainfrom
mr/space-lookup-endpoint
Oct 14, 2026
Merged

matt-richardson merged 8 commits into
mainfrom
mr/space-lookup-endpoint

Conversation

@matt-richardson

Copy link
Copy Markdown
Contributor

Part of DPT-3630 (Renaming an Octopus space breaks TeamCity configurations that name it). Stacked on #261.

Why

The space picker needs to list the spaces on a connection's Octopus server, which means a server-side endpoint, /octopus/listSpaces.html. Nothing calls it yet; the picker UI comes in the next PR. This PR covers only connections that store their API key. Parameter-held keys and OIDC follow separately, and until then those connections get a message asking for the space name instead.

Security

The endpoint makes an outbound request on the caller's behalf, so it is deliberately narrow, and each point has a test:

  • The caller must be logged in and hold EDIT_PROJECT on the project. That is the same permission needed to configure a connection at all, so it grants no reach they did not already have.
  • The request only names a saved connection. It never supplies a URL or key, so the server only ever calls addresses an admin has already saved into project configuration. Posted serverUrl/apiKey values are ignored.
  • The URL must be http(s) with a host, and redirects are not followed, so the key is never replayed elsewhere.
  • The API key is never echoed back, and responses are Cache-Control: no-store.

A side effect of naming a saved connection: a brand-new connection must be saved once before its spaces can be listed. That's unavoidable anyway, because TeamCity renders a saved secret as a placeholder, so the browser never holds the real key.

Notes

The lookup uses HttpURLConnection and gson, following CommitHistoryFetcher, rather than com.octopus:octopus-sdk. The SDK is test-scope only today and would drag a gson upgrade into the shipped plugin.

🤖 Generated with Claude Code

matt-richardson and others added 2 commits October 14, 2026 10:09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…API key

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
matt-richardson and others added 3 commits October 14, 2026 11:38
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from mr/space-id-storage to main October 14, 2026 00:42

@APErebus APErebus 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.

LGTM. Just 1 nit that might be worth fixing

Comment on lines +87 to +88
"The Octopus server did not return a spaces list. Check the URL points at an Octopus"
+ " server.");

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.

The `"Check the URL points at an Octopus server." is a slightly strange error message imo

Comment on lines +36 to +37
/** How many spaces we ask for. Far above any realistic instance. */
static final int TAKE = 1000;

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.

you might as well do int.MaxValue (or the java equivalent) so you just get all of them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matt-richardson
matt-richardson enabled auto-merge (squash) October 14, 2026 04:58
@matt-richardson
matt-richardson merged commit b48078e into main Oct 14, 2026
5 checks passed
@matt-richardson
matt-richardson deleted the mr/space-lookup-endpoint branch October 14, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants