Skip to content

Commit 34467a3

Browse files
authored
feat: add github device flow for authentication (#8232)
* feat: add github device flow for authentication This will allow us to add a GitHub OAuth provider out-of-the-box to reduce setup requirements. * Improve askpass view * Add routes to improve clarity of git auth * Redesign the git auth page * Refactor to add a page view * Fix sideways layout * Remove legacy notify * Fix git auth redirects * Add E2E tests * Fix route documentation * Fix imports * Remove unused imports * Fix E2E web test * Fix friendly message appearance * Fix layout shifting for full-screen sign-in * Fix height going to 100% * Fix comments
1 parent 7f82eca commit 34467a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2740
-508
lines changed

cli/cliui/gitauth_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cliui_test
22

33
import (
44
"context"
5-
"net/url"
65
"sync/atomic"
76
"testing"
87
"time"
@@ -33,7 +32,7 @@ func TestGitAuth(t *testing.T) {
3332
ID: "github",
3433
Type: codersdk.GitProviderGitHub,
3534
Authenticated: fetched.Load(),
36-
AuthenticateURL: "https://example.com/gitauth/github?redirect=" + url.QueryEscape("/gitauth?notify"),
35+
AuthenticateURL: "https://example.com/gitauth/github",
3736
}}, nil
3837
},
3938
FetchInterval: time.Millisecond,

cli/gitaskpass.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ func (r *RootCmd) gitAskpass() *clibase.Cmd {
5151
}
5252
if token.URL != "" {
5353
if err := openURL(inv, token.URL); err == nil {
54-
cliui.Infof(inv.Stderr, "Your browser has been opened to authenticate with Git:\n\n\t%s\n\n", token.URL)
54+
cliui.Infof(inv.Stderr, "Your browser has been opened to authenticate with Git:\n\n%s\n", token.URL)
5555
} else {
56-
cliui.Infof(inv.Stderr, "Open the following URL to authenticate with Git:\n\n\t%s\n\n", token.URL)
56+
cliui.Infof(inv.Stderr, "Open the following URL to authenticate with Git:\n\n%s\n", token.URL)
5757
}
5858

5959
for r := retry.New(250*time.Millisecond, 10*time.Second); r.Wait(ctx); {

cli/server.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ func ReadGitAuthProvidersFromEnv(environ []string) ([]codersdk.GitAuthConfig, er
148148
provider.ValidateURL = v.Value
149149
case "REGEX":
150150
provider.Regex = v.Value
151+
case "DEVICE_FLOW":
152+
b, err := strconv.ParseBool(v.Value)
153+
if err != nil {
154+
return nil, xerrors.Errorf("parse bool: %s", v.Value)
155+
}
156+
provider.DeviceFlow = b
157+
case "DEVICE_CODE_URL":
158+
provider.DeviceCodeURL = v.Value
151159
case "NO_REFRESH":
152160
b, err := strconv.ParseBool(v.Value)
153161
if err != nil {
@@ -156,6 +164,10 @@ func ReadGitAuthProvidersFromEnv(environ []string) ([]codersdk.GitAuthConfig, er
156164
provider.NoRefresh = b
157165
case "SCOPES":
158166
provider.Scopes = strings.Split(v.Value, " ")
167+
case "APP_INSTALL_URL":
168+
provider.AppInstallURL = v.Value
169+
case "APP_INSTALLATIONS_URL":
170+
provider.AppInstallationsURL = v.Value
159171
}
160172
providers[providerNum] = provider
161173
}

coderd/apidoc/docs.go

Lines changed: 197 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy