Skip to content

Commit e204190

Browse files
committed
add front proxy as an option for authenticating to the API
1 parent 29e3a46 commit e204190

File tree

5 files changed

+107
-0
lines changed

5 files changed

+107
-0
lines changed

pkg/cmd/server/api/types.go

+27
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ type MasterConfig struct {
252252
// ServingInfo describes how to start serving
253253
ServingInfo HTTPServingInfo
254254

255+
// AuthConfig configures authentication options in addition to the standard
256+
// oauth token and client certificate authenticators
257+
AuthConfig MasterAuthConfig
258+
255259
// CORSAllowedOrigins
256260
CORSAllowedOrigins []string
257261

@@ -342,6 +346,29 @@ type MasterConfig struct {
342346
AuditConfig AuditConfig
343347
}
344348

349+
// MasterAuthConfig configures authentication options in addition to the standard
350+
// oauth token and client certificate authenticators
351+
type MasterAuthConfig struct {
352+
// RequestHeader holds options for setting up a front proxy against the the API. It is optional.
353+
RequestHeader *RequestHeaderAuthenticationOptions
354+
}
355+
356+
// RequestHeaderAuthenticationOptions provides options for setting up a front proxy against the entire
357+
// API instead of against the /oauth endpoint.
358+
type RequestHeaderAuthenticationOptions struct {
359+
// ClientCA is a file with the trusted signer certs. It is required.
360+
ClientCA string
361+
// ClientCommonNames is a required list of common names to require a match from.
362+
ClientCommonNames []string
363+
364+
// UsernameHeaders is the list of headers to check for user information. First hit wins.
365+
UsernameHeaders []string
366+
// GroupNameHeader is the set of headers to check for group information. All are unioned.
367+
GroupHeaders []string
368+
// ExtraHeaderPrefixes is the set of request header prefixes to inspect for user extra. X-Remote-Extra- is suggested.
369+
ExtraHeaderPrefixes []string
370+
}
371+
345372
// AuditConfig holds configuration for the audit capabilities
346373
type AuditConfig struct {
347374
// If this flag is set, audit log will be printed in the logs.

pkg/cmd/server/api/v1/swagger_doc.go

+23
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,15 @@ func (LocalQuota) SwaggerDoc() map[string]string {
431431
return map_LocalQuota
432432
}
433433

434+
var map_MasterAuthConfig = map[string]string{
435+
"": "MasterAuthConfig configures authentication options in addition to the standard oauth token and client certificate authenticators",
436+
"requestHeader": "RequestHeader holds options for setting up a front proxy against the the API. It is optional.",
437+
}
438+
439+
func (MasterAuthConfig) SwaggerDoc() map[string]string {
440+
return map_MasterAuthConfig
441+
}
442+
434443
var map_MasterClients = map[string]string{
435444
"": "MasterClients holds references to `.kubeconfig` files that qualify master clients for OpenShift and Kubernetes",
436445
"openshiftLoopbackKubeConfig": "OpenShiftLoopbackKubeConfig is a .kubeconfig filename for system components to loopback to this master",
@@ -446,6 +455,7 @@ func (MasterClients) SwaggerDoc() map[string]string {
446455
var map_MasterConfig = map[string]string{
447456
"": "MasterConfig holds the necessary configuration options for the OpenShift master",
448457
"servingInfo": "ServingInfo describes how to start serving",
458+
"authConfig": "AuthConfig configures authentication options in addition to the standard oauth token and client certificate authenticators",
449459
"corsAllowedOrigins": "CORSAllowedOrigins",
450460
"apiLevels": "APILevels is a list of API levels that should be enabled on startup: v1 as examples",
451461
"masterPublicURL": "MasterPublicURL is how clients can access the OpenShift API server",
@@ -701,6 +711,19 @@ func (RemoteConnectionInfo) SwaggerDoc() map[string]string {
701711
return map_RemoteConnectionInfo
702712
}
703713

714+
var map_RequestHeaderAuthenticationOptions = map[string]string{
715+
"": "RequestHeaderAuthenticationOptions provides options for setting up a front proxy against the entire API instead of against the /oauth endpoint.",
716+
"clientCA": "ClientCA is a file with the trusted signer certs. It is required.",
717+
"clientCommonNames": "ClientCommonNames is a required list of common names to require a match from.",
718+
"usernameHeaders": "UsernameHeaders is the list of headers to check for user information. First hit wins.",
719+
"groupHeaders": "GroupNameHeader is the set of headers to check for group information. All are unioned.",
720+
"extraHeaderPrefixes": "ExtraHeaderPrefixes is the set of request header prefixes to inspect for user extra. X-Remote-Extra- is suggested.",
721+
}
722+
723+
func (RequestHeaderAuthenticationOptions) SwaggerDoc() map[string]string {
724+
return map_RequestHeaderAuthenticationOptions
725+
}
726+
704727
var map_RequestHeaderIdentityProvider = map[string]string{
705728
"": "RequestHeaderIdentityProvider provides identities for users authenticating using request header credentials",
706729
"loginURL": "LoginURL is a URL to redirect unauthenticated /authorize requests to Unauthenticated requests from OAuth clients which expect interactive logins will be redirected here ${url} is replaced with the current URL, escaped to be safe in a query parameter\n https://www.example.com/sso-login?then=${url}\n${query} is replaced with the current query string\n https://www.example.com/auth-proxy/oauth/authorize?${query}",

pkg/cmd/server/api/v1/types.go

+27
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ type MasterConfig struct {
174174
// ServingInfo describes how to start serving
175175
ServingInfo HTTPServingInfo `json:"servingInfo"`
176176

177+
// AuthConfig configures authentication options in addition to the standard
178+
// oauth token and client certificate authenticators
179+
AuthConfig MasterAuthConfig `json:"authConfig"`
180+
177181
// CORSAllowedOrigins
178182
CORSAllowedOrigins []string `json:"corsAllowedOrigins"`
179183

@@ -264,6 +268,29 @@ type MasterConfig struct {
264268
AuditConfig AuditConfig `json:"auditConfig"`
265269
}
266270

271+
// MasterAuthConfig configures authentication options in addition to the standard
272+
// oauth token and client certificate authenticators
273+
type MasterAuthConfig struct {
274+
// RequestHeader holds options for setting up a front proxy against the the API. It is optional.
275+
RequestHeader *RequestHeaderAuthenticationOptions `json:"requestHeader"`
276+
}
277+
278+
// RequestHeaderAuthenticationOptions provides options for setting up a front proxy against the entire
279+
// API instead of against the /oauth endpoint.
280+
type RequestHeaderAuthenticationOptions struct {
281+
// ClientCA is a file with the trusted signer certs. It is required.
282+
ClientCA string `json:"clientCA"`
283+
// ClientCommonNames is a required list of common names to require a match from.
284+
ClientCommonNames []string `json:"clientCommonNames"`
285+
286+
// UsernameHeaders is the list of headers to check for user information. First hit wins.
287+
UsernameHeaders []string `json:"usernameHeaders"`
288+
// GroupNameHeader is the set of headers to check for group information. All are unioned.
289+
GroupHeaders []string `json:"groupHeaders"`
290+
// ExtraHeaderPrefixes is the set of request header prefixes to inspect for user extra. X-Remote-Extra- is suggested.
291+
ExtraHeaderPrefixes []string `json:"extraHeaderPrefixes"`
292+
}
293+
267294
// AuditConfig holds configuration for the audit capabilities
268295
type AuditConfig struct {
269296
// If this flag is set, audit log will be printed in the logs.

pkg/cmd/server/api/v1/types_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ auditConfig:
112112
maximumFileRetentionDays: 0
113113
maximumFileSizeMegabytes: 0
114114
maximumRetainedFiles: 0
115+
authConfig:
116+
requestHeader: null
115117
controllerConfig:
116118
serviceServingCert:
117119
signer: null

pkg/cmd/server/api/validation/master.go

+28
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,34 @@ func ValidateMasterConfig(config *api.MasterConfig, fldPath *field.Path) Validat
193193

194194
validationResults.Append(ValidateAuditConfig(config.AuditConfig, fldPath.Child("auditConfig")))
195195

196+
validationResults.Append(ValidateMasterAuthConfig(config.AuthConfig, fldPath.Child("authConfig")))
197+
198+
return validationResults
199+
}
200+
201+
func ValidateMasterAuthConfig(config api.MasterAuthConfig, fldPath *field.Path) ValidationResults {
202+
validationResults := ValidationResults{}
203+
204+
if config.RequestHeader == nil {
205+
return validationResults
206+
}
207+
208+
if len(config.RequestHeader.ClientCA) == 0 {
209+
validationResults.AddErrors(field.Required(fldPath.Child("requestHeader.clientCA"), "must be specified for a secure connection"))
210+
}
211+
if len(config.RequestHeader.ClientCommonNames) == 0 {
212+
validationResults.AddErrors(field.Required(fldPath.Child("requestHeader.clientCommonNames"), "must be specified for a secure connection"))
213+
}
214+
if len(config.RequestHeader.UsernameHeaders) == 0 {
215+
validationResults.AddErrors(field.Required(fldPath.Child("requestHeader.usernameHeaders"), "must be specified for a secure connection"))
216+
}
217+
if len(config.RequestHeader.GroupHeaders) == 0 {
218+
validationResults.AddErrors(field.Required(fldPath.Child("requestHeader.groupHeaders"), "must be specified for a secure connection"))
219+
}
220+
if len(config.RequestHeader.ExtraHeaderPrefixes) == 0 {
221+
validationResults.AddErrors(field.Required(fldPath.Child("requestHeader.extraHeaderPrefixes"), "must be specified for a secure connection"))
222+
}
223+
196224
return validationResults
197225
}
198226

0 commit comments

Comments
 (0)