Skip to content

Commit cb889d4

Browse files
committed
Fix authorization-config/authentication-config handling
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
1 parent effe6ce commit cb889d4

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

pkg/daemons/control/server.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,15 @@ func apiServer(ctx context.Context, cfg *config.Control) error {
211211
argsMap["cert-dir"] = certDir
212212
argsMap["allow-privileged"] = "true"
213213
argsMap["enable-bootstrap-token-auth"] = "true"
214-
if authConfigFile := util.ArgValue("authorization-config", cfg.ExtraAPIArgs); authConfigFile == "" {
215-
logrus.Warn("Not setting kube-apiserver 'authorization-mode' and 'anonymous-auth' flags due to user-provided 'authorization-config' file.")
214+
if util.ArgValue("authorization-config", cfg.ExtraAPIArgs) == "" {
216215
argsMap["authorization-mode"] = strings.Join([]string{modes.ModeNode, modes.ModeRBAC}, ",")
216+
} else {
217+
logrus.Warn("Not setting kube-apiserver 'authorization-mode' flag due to user-provided 'authorization-config' file.")
218+
}
219+
if util.ArgValue("authentication-config", cfg.ExtraAPIArgs) == "" {
217220
argsMap["anonymous-auth"] = "false"
221+
} else {
222+
logrus.Warn("Not setting kube-apiserver 'anonymous-auth' flag due to user-provided 'authentication-config' file.")
218223
}
219224
argsMap["service-account-signing-key-file"] = runtime.ServiceCurrentKey
220225
argsMap["service-cluster-ip-range"] = util.JoinIPNets(cfg.ServiceIPRanges)

pkg/daemons/control/server_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func Test_UnitServer(t *testing.T) {
103103
},
104104
},
105105
{
106-
name: "ControlPlane+Kine with authorization-config",
106+
name: "ControlPlane+Kine with auth config",
107107
setup: func(ctx context.Context, t *testing.T) (*config.Control, error) {
108108
control, err := mockControl(ctx, t, false)
109109
if err != nil {
@@ -114,10 +114,11 @@ func Test_UnitServer(t *testing.T) {
114114

115115
executor := mock.NewExecutorWithEmbeddedETCD(t)
116116

117-
// authorization-mode and anonymous-auth should not be set when user sets --authorization-config
118-
control.ExtraAPIArgs = []string{"authorization-config=/dev/null"}
117+
// authorization-mode and anonymous-auth should not be set when user sets --authorization-config and --authentication-config
118+
control.ExtraAPIArgs = []string{"authorization-config=/dev/null", "authentication-config=/dev/null"}
119119
matchAuthArgs := mock.GM(And(
120120
ContainElement(ContainSubstring("--authorization-config")),
121+
ContainElement(ContainSubstring("--authentication-config")),
121122
Not(ContainElement(ContainSubstring("--authorization-mode"))),
122123
Not(ContainElement(ContainSubstring("--anonymous-auth"))),
123124
))

0 commit comments

Comments
 (0)