Skip to content

Give the portal a way to connect a provider that takes an api key - #32

Merged
fajarhide merged 1 commit into
mainfrom
fix/admin-api-key-connections
Aug 17, 2026
Merged

Give the portal a way to connect a provider that takes an api key#32
fajarhide merged 1 commit into
mainfrom
fix/admin-api-key-connections

Conversation

@fajarhide

Copy link
Copy Markdown
Owner

Clicking Connect on Discord in the portal returns a 500. The portal drives every
provider through POST /v1/admin/workspaces/:id/connections/:prefix/authorize,
Discord takes a bot token rather than a consent, so beginConnection answers 400
and the unhandled throw in the server action becomes a 500 page.

The portal could not have done better with what this API gave it. The admin
connections list sends provider, grant, maturity, scopes, connected, so
nothing says which providers want a consent window and which want a secret. And
PUT /v1/connections/:prefix/key sits on the tenant router behind the workspace
credential, which the portal does not hold. There was no route to a working
Discord connection at all.

So: credential rides along on the admin list, and
PUT /v1/admin/workspaces/:id/connections/:prefix/key writes through the same
setApiKey path, with the workspace check and audit row its sibling routes carry.
The key is never echoed back and the audit row records only that it changed.

Test Files  37 passed (37)
     Tests  365 passed (365)
tsc --noEmit: clean

Portal side is a separate PR in selat-cloud, and it needs this one first.

…it somewhere to put one

The portal drives every provider through POST .../connections/:prefix/authorize.
Discord takes a bot token rather than a consent, so that call answers 400 and the
portal turns the throw into a 500 on its connections page.

It could not have done better. The admin connections list sent provider, grant,
maturity, scopes and connected, so nothing in it says whether a provider wants a
consent window or a secret. And PUT /v1/connections/:prefix/key is on the tenant
router, authenticated by the workspace credential, which the portal does not
hold. So there was no route to a working Discord connection at all.

Two additions, both mirroring what the tenant router already does: credential
rides along on the admin list, and PUT /v1/admin/workspaces/:id/connections/
:prefix/key writes the key through the same setApiKey path, with the workspace
check and the audit row the sibling routes carry.

The key is never echoed back and the audit row records only that it changed.
@fajarhide
fajarhide merged commit f28782a into main Aug 17, 2026
2 checks passed
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