Give the portal a way to connect a provider that takes an api key - #32
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
beginConnectionanswers 400and 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, sonothing says which providers want a consent window and which want a secret. And
PUT /v1/connections/:prefix/keysits on the tenant router behind the workspacecredential, which the portal does not hold. There was no route to a working
Discord connection at all.
So:
credentialrides along on the admin list, andPUT /v1/admin/workspaces/:id/connections/:prefix/keywrites through the samesetApiKeypath, 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.
Portal side is a separate PR in selat-cloud, and it needs this one first.