Skip to content

add an option to disconnect from a route that needs upstream oauth#121

Merged
wasaga merged 6 commits intomainfrom
wasaga/upstream-disconnect
Jul 8, 2025
Merged

add an option to disconnect from a route that needs upstream oauth#121
wasaga merged 6 commits intomainfrom
wasaga/upstream-disconnect

Conversation

@wasaga
Copy link
Copy Markdown
Collaborator

@wasaga wasaga commented Jul 8, 2025

if a route needs an upstream oauth, sometimes the user needs to purge its upstream authentication so that it can re-acquire it again, possibly with different scopes and options.

adds a ui component that allows to do that.
image

Ref: https://linear.app/pomerium/issue/ENG-2545/mcp-user-should-be-able-to-purge-their-upstream-oauth2-token

Depends on: pomerium/pomerium#5707

Copilot AI review requested due to automatic review settings July 8, 2025 15:59

This comment was marked as outdated.

@wasaga wasaga requested review from Copilot and nickytonline July 8, 2025 16:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a “disconnect” option so users can purge their upstream OAuth token and reconnect with new scopes.

  • Extends Zod schemas with disconnectRequestSchema/disconnectResponseSchema and needs_oauth flags
  • Implements disconnectFromServer logic and UI button in ServerSelector
  • Adds tests covering button rendering and the POST request to the disconnect endpoint

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/lib/schemas.ts Added needs_oauth to server schemas and defined disconnect request/response schemas and types
src/components/ServerSelector.tsx Imported new schemas, defined POMERIUM_DISCONNECT_ENDPOINT, added disconnectFromServer logic, modified JSX/CSS to render a disconnect button when appropriate
src/components/ServerSelector.test.tsx Added tests for showing/hiding the disconnect button and verifying the POST call and event prevention behavior
Comments suppressed due to low confidence (1)

src/components/ServerSelector.test.tsx:185

  • After triggering the disconnect fetch, add an assertion to verify that onServersChange is called with the updated server list so the UI state is correctly updated.
    expect(disconnectFetch).toHaveBeenCalledWith(

window.location.href = connectUrl
}

const disconnectFromServer = async (serverId: string) => {
Copy link

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The disconnectFromServer function is doing multiple responsibilities (validation, fetch, parsing, state mapping). Consider extracting its logic into a custom hook or utility module to improve readability and testability.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@nickytonline
Copy link
Copy Markdown
Member

nickytonline commented Jul 8, 2025

I opted for an unplug icon instead of the X @wasaga which aligns more with the aesthetic of the app.

Before

image

After

CleanShot 2025-07-08 at 14 19 16@2x

@wasaga wasaga merged commit c6424f2 into main Jul 8, 2025
2 checks passed
@wasaga wasaga deleted the wasaga/upstream-disconnect branch July 8, 2025 23:39
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.

3 participants