Skip to content

Commit c8600e1

Browse files
authored
Merge pull request #6463 from thaJeztah/remove_oauth_escape_hatch
remove DOCKER_CLI_DISABLE_OAUTH_LOGIN escape hatch
2 parents 4a4043c + 71f4605 commit c8600e1

File tree

3 files changed

+1
-87
lines changed

3 files changed

+1
-87
lines changed

cli/command/registry/login.go

Lines changed: 1 addition & 21 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,24 +181,6 @@ func loginWithStoredCredentials(ctx context.Context, dockerCLI command.Cli, auth
183181
return response.Status, err
184182
}
185183

186-
// OauthLoginEscapeHatchEnvVar disables the browser-based OAuth login workflow.
187-
//
188-
// Deprecated: this const was only used internally and will be removed in the next release.
189-
const OauthLoginEscapeHatchEnvVar = "DOCKER_CLI_DISABLE_OAUTH_LOGIN"
190-
191-
const oauthLoginEscapeHatchEnvVar = "DOCKER_CLI_DISABLE_OAUTH_LOGIN"
192-
193-
func isOauthLoginDisabled() bool {
194-
if v := os.Getenv(oauthLoginEscapeHatchEnvVar); v != "" {
195-
enabled, err := strconv.ParseBool(v)
196-
if err != nil {
197-
return false
198-
}
199-
return enabled
200-
}
201-
return false
202-
}
203-
204184
func loginUser(ctx context.Context, dockerCLI command.Cli, opts loginOptions, defaultUsername, serverAddress string) (msg string, _ error) {
205185
// Some links documenting this:
206186
// - https://code.google.com/archive/p/mintty/issues/56
@@ -214,7 +194,7 @@ func loginUser(ctx context.Context, dockerCLI command.Cli, opts loginOptions, de
214194
}
215195

216196
// If we're logging into the index server and the user didn't provide a username or password, use the device flow
217-
if serverAddress == registry.IndexServer && opts.user == "" && opts.password == "" && !isOauthLoginDisabled() {
197+
if serverAddress == registry.IndexServer && opts.user == "" && opts.password == "" {
218198
var err error
219199
msg, err = loginWithDeviceCodeFlow(ctx, dockerCLI)
220200
// 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)