feat: prompt for API key when server requires authentication#48
Merged
Conversation
Servers with auth enabled return 401/403 on unauthenticated requests.
Previously the client would silently fail or show a generic error.
- Add `checkAuth()` to ReasonDBClient — probes /v1/tables without auth
and returns `{ authRequired: true }` on 401/403
- Add `updateApiKey()` to apply a key to an existing client instance
- Add ApiKeyPromptDialog — modal that validates the key by calling
listTables() before completing the connection
- Wire into Sidebar.handleConnect: if the server requires auth, park the
client and show the prompt instead of failing
- Wire into App startup: if a persisted connection has no stored key and
the server now requires auth, drop it back to the connection list
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.
Summary
401/403on unauthenticated requests. Previously the client silently failed or showed a generic connection error with no way to enter credentials.Changes
src/lib/api.tscheckAuth()— probes/v1/tableswithout credentials; returns{ authRequired: true }on401/403, gracefully ignores network errors so it never blocks the connect flowupdateApiKey()— applies a key to an existing in-memory client instance after the prompt is confirmedsrc/components/connection/ApiKeyPromptDialog.tsx(new)listTables()before completing — shows "Invalid API key" if the server rejects itsrc/components/layout/Sidebar.tsxhandleConnectnow probes for auth after a successful connection testpendingAuthConnection, shows the dialoghandleApiKeySubmitapplies the key, callslistTables()to validate, then finalisessetClient/setActiveConnectionsrc/App.tsxapiKeyand the server now requires one, dropsactiveConnectionback tonullso the user lands on the connection list instead of a broken sessionTest plan