Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bug: github device auth never completes if the user doesn't view the coder page with code again #18470

Open
@hugodutka

Description

@hugodutka

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The flow to connect GitHub external auth to Coder using the device flow is as follows:

  1. User clicks on the "Login with GitHub" button on https://dev.coder.com/settings/external-auth
  2. User is redirected https://dev.coder.com/external-auth/github
  3. User copies code, opens GitHub, pastes the code, authorizes Coder
  4. User goes back to https://dev.coder.com/external-auth/github. The page polls https://dev.coder.com/api/v2/external-auth/github/device every 5 seconds, which in turn polls GitHub. If the user completed the GitHub authorization process, Coder receives OAuth tokens from GitHub, and saves external auth information in the database.

However, if the user completes step 3 but doesn't move on to step 4, Coder will not poll GitHub and never complete the authentication flow. This can very easily happen on Windows with Chrome when the https://dev.coder.com/external-auth/github page is opened in a pop up window. The user only opens the window to copy the code - there's no natural reason to go back once they complete the flow on GitHub's side. @Jphalan ran into this: he'd go back to https://dev.coder.com/settings/external-auth instead and see a never-ending spinner.

A possible fix is to set refetchIntervalInBackground: true on

const exchangeExternalAuthDeviceQuery = useQuery({
so that the browser keeps polling Coder even when the user is not looking at the page.

Relevant Log Output

Expected Behavior

No response

Steps to Reproduce

See above.

Environment

  • Host OS:
  • Coder version:

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue that require triage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions