@@ -61,6 +61,10 @@ import (
61
61
netutils "k8s.io/utils/net"
62
62
)
63
63
64
+ const (
65
+ UnprivilegedUserToken = "unprivileged-user"
66
+ )
67
+
64
68
// Config is a struct of configuration directives for NewControlPlaneComponents.
65
69
type Config struct {
66
70
// If nil, a default is used, partially filled configs will not get populated.
@@ -80,11 +84,16 @@ func (alwaysAllow) Authorize(ctx context.Context, requestAttributes authorizer.A
80
84
return authorizer .DecisionAllow , "always allow" , nil
81
85
}
82
86
83
- // alwaysEmpty simulates "no authentication" for old tests
84
- func alwaysEmpty (req * http.Request ) (* authauthenticator.Response , bool , error ) {
87
+ // unsecuredUser simulates requests to the unsecured endpoint for old tests
88
+ func unsecuredUser (req * http.Request ) (* authauthenticator.Response , bool , error ) {
89
+ auth := req .Header .Get ("Authorization" )
90
+ if len (auth ) != 0 {
91
+ return nil , false , nil
92
+ }
85
93
return & authauthenticator.Response {
86
94
User : & user.DefaultInfo {
87
- Name : "" ,
95
+ Name : "system:unsecured" ,
96
+ Groups : []string {user .SystemPrivilegedGroup , user .AllAuthenticated },
88
97
},
89
98
}, true , nil
90
99
}
@@ -171,12 +180,17 @@ func startAPIServerOrDie(controlPlaneConfig *controlplane.Config, incomingServer
171
180
tokens [privilegedLoopbackToken ] = & user.DefaultInfo {
172
181
Name : user .APIServerUser ,
173
182
UID : uuid .New ().String (),
174
- Groups : []string {user .SystemPrivilegedGroup },
183
+ Groups : []string {user .SystemPrivilegedGroup , user .AllAuthenticated },
184
+ }
185
+ tokens [UnprivilegedUserToken ] = & user.DefaultInfo {
186
+ Name : "unprivileged" ,
187
+ UID : uuid .New ().String (),
188
+ Groups : []string {user .AllAuthenticated },
175
189
}
176
190
177
191
tokenAuthenticator := authenticatorfactory .NewFromTokens (tokens , controlPlaneConfig .GenericConfig .Authentication .APIAudiences )
178
192
if controlPlaneConfig .GenericConfig .Authentication .Authenticator == nil {
179
- controlPlaneConfig .GenericConfig .Authentication .Authenticator = authenticatorunion .New (tokenAuthenticator , authauthenticator .RequestFunc (alwaysEmpty ))
193
+ controlPlaneConfig .GenericConfig .Authentication .Authenticator = authenticatorunion .New (tokenAuthenticator , authauthenticator .RequestFunc (unsecuredUser ))
180
194
} else {
181
195
controlPlaneConfig .GenericConfig .Authentication .Authenticator = authenticatorunion .New (tokenAuthenticator , controlPlaneConfig .GenericConfig .Authentication .Authenticator )
182
196
}
0 commit comments