gcp-cherry-pick-bot[bot] 6da3c9d48c fix: allow orgs with default github provider (cherry-pick #16755) (#16784)
Cherry-picked fix: allow orgs with default github provider (#16755)

This PR fixes 2 bugs:

## Problem 1

The server would fail to start when the default github provider was
configured and the flag `--oauth2-github-allowed-orgs` was set. The
error was

```
error: configure github oauth2: allow everyone and allowed orgs cannot be used together
```

This PR fixes it by enabling "allow everone" with the default provider
only if "allowed orgs" isn't set.

## Problem 2

The default github provider uses the device flow to authorize users, and
that's handled differently by our web UI than the standard oauth flow.
In particular, the web UI only handles JSON responses rather than HTTP
redirects. There were 2 code paths that returned redirects, and the PR
changes them to return JSON messages instead if the device flow is
configured.

Co-authored-by: Hugo Dutka <hugo@coder.com>
2025-03-03 17:49:35 -06:00
..