Skip to content

Commit 71f4605

Browse files
committed
remove DOCKER_CLI_DISABLE_OAUTH_LOGIN escape hatch
This code was added in 846ecf5 as an escape hatch in case the new OAuth login flow would cause problems. We have not received reports where the new flow caused problems, and searching the internet shows no mentions of the env-var. This env-var was not documented, so we can remove it. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 083e5ce commit 71f4605

File tree

3 files changed

+1
-82
lines changed

3 files changed

+1
-82
lines changed

cli/command/registry/login.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import (
55
"errors"
66
"fmt"
77
"io"
8-
"os"
9-
"strconv"
108
"strings"
119

1210
"github.com/containerd/errdefs"
@@ -183,19 +181,6 @@ func loginWithStoredCredentials(ctx context.Context, dockerCLI command.Cli, auth
183181
return response.Status, err
184182
}
185183

186-
const oauthLoginEscapeHatchEnvVar = "DOCKER_CLI_DISABLE_OAUTH_LOGIN"
187-
188-
func isOauthLoginDisabled() bool {
189-
if v := os.Getenv(oauthLoginEscapeHatchEnvVar); v != "" {
190-
enabled, err := strconv.ParseBool(v)
191-
if err != nil {
192-
return false
193-
}
194-
return enabled
195-
}
196-
return false
197-
}
198-
199184
func loginUser(ctx context.Context, dockerCLI command.Cli, opts loginOptions, defaultUsername, serverAddress string) (msg string, _ error) {
200185
// Some links documenting this:
201186
// - https://code.google.com/archive/p/mintty/issues/56
@@ -209,7 +194,7 @@ func loginUser(ctx context.Context, dockerCLI command.Cli, opts loginOptions, de
209194
}
210195

211196
// If we're logging into the index server and the user didn't provide a username or password, use the device flow
212-
if serverAddress == registry.IndexServer && opts.user == "" && opts.password == "" && !isOauthLoginDisabled() {
197+
if serverAddress == registry.IndexServer && opts.user == "" && opts.password == "" {
213198
var err error
214199
msg, err = loginWithDeviceCodeFlow(ctx, dockerCLI)
215200
// if the error represents a failure to initiate the device-code flow,

cli/command/registry/login_test.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -497,50 +497,6 @@ func TestLoginTermination(t *testing.T) {
497497
}
498498
}
499499

500-
func TestIsOauthLoginDisabled(t *testing.T) {
501-
testCases := []struct {
502-
envVar string
503-
disabled bool
504-
}{
505-
{
506-
envVar: "",
507-
disabled: false,
508-
},
509-
{
510-
envVar: "bork",
511-
disabled: false,
512-
},
513-
{
514-
envVar: "0",
515-
disabled: false,
516-
},
517-
{
518-
envVar: "false",
519-
disabled: false,
520-
},
521-
{
522-
envVar: "true",
523-
disabled: true,
524-
},
525-
{
526-
envVar: "TRUE",
527-
disabled: true,
528-
},
529-
{
530-
envVar: "1",
531-
disabled: true,
532-
},
533-
}
534-
535-
for _, tc := range testCases {
536-
t.Setenv(oauthLoginEscapeHatchEnvVar, tc.envVar)
537-
538-
disabled := isOauthLoginDisabled()
539-
540-
assert.Equal(t, disabled, tc.disabled)
541-
}
542-
}
543-
544500
func TestLoginValidateFlags(t *testing.T) {
545501
for _, tc := range []struct {
546502
name string

e2e/registry/login_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,3 @@ func TestOauthLogin(t *testing.T) {
3232
output, _ := io.ReadAll(p)
3333
assert.Check(t, strings.Contains(string(output), "USING WEB-BASED LOGIN"), string(output))
3434
}
35-
36-
func TestLoginWithEscapeHatch(t *testing.T) {
37-
t.Parallel()
38-
loginCmd := exec.Command("docker", "login")
39-
loginCmd.Env = append(loginCmd.Env, "DOCKER_CLI_DISABLE_OAUTH_LOGIN=1")
40-
41-
p, err := pty.Start(loginCmd)
42-
assert.NilError(t, err)
43-
defer func() {
44-
_ = loginCmd.Wait()
45-
_ = p.Close()
46-
}()
47-
48-
time.Sleep(1 * time.Second)
49-
pid := loginCmd.Process.Pid
50-
t.Logf("terminating PID %d", pid)
51-
err = syscall.Kill(pid, syscall.SIGTERM)
52-
assert.NilError(t, err)
53-
54-
output, _ := io.ReadAll(p)
55-
assert.Check(t, strings.Contains(string(output), "Username:"), string(output))
56-
}

0 commit comments

Comments
 (0)