Skip to content

Commit 98bf37e

Browse files
committed
wire up front proxy authenticator
1 parent e204190 commit 98bf37e

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

pkg/cmd/server/origin/master_config.go

+21-8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"k8s.io/kubernetes/plugin/pkg/admission/namespace/lifecycle"
3434
saadmit "k8s.io/kubernetes/plugin/pkg/admission/serviceaccount"
3535
storageclassdefaultadmission "k8s.io/kubernetes/plugin/pkg/admission/storageclass/default"
36+
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/headerrequest"
3637

3738
"github.com/openshift/origin/pkg/auth/authenticator"
3839
"github.com/openshift/origin/pkg/auth/authenticator/anonymous"
@@ -664,16 +665,28 @@ func newAuthenticator(config configapi.MasterConfig, restOptionsGetter restoptio
664665
authenticators = append(authenticators, certauth)
665666
}
666667

667-
ret := &unionrequest.Authenticator{
668-
FailOnError: true,
669-
Handlers: []authenticator.Request{
670-
// if you change this, have a look at the impersonationFilter where we attach groups to the impersonated user
671-
group.NewGroupAdder(&unionrequest.Authenticator{FailOnError: true, Handlers: authenticators}, []string{bootstrappolicy.AuthenticatedGroup}),
672-
anonymous.NewAuthenticator(),
673-
},
668+
topLevelAuthenticators := []authenticator.Request{}
669+
// if we have a front proxy providing authentication configuration, wire it up and it should come first
670+
if config.AuthConfig.RequestHeader != nil {
671+
requestHeaderAuthenticator, err := headerrequest.NewSecure(
672+
config.AuthConfig.RequestHeader.ClientCA,
673+
config.AuthConfig.RequestHeader.ClientCommonNames,
674+
config.AuthConfig.RequestHeader.UsernameHeaders,
675+
config.AuthConfig.RequestHeader.GroupHeaders,
676+
config.AuthConfig.RequestHeader.ExtraHeaderPrefixes,
677+
)
678+
if err != nil {
679+
return nil, err
680+
}
681+
topLevelAuthenticators = append(topLevelAuthenticators, requestHeaderAuthenticator)
674682
}
683+
topLevelAuthenticators = append(topLevelAuthenticators, group.NewGroupAdder(&unionrequest.Authenticator{FailOnError: true, Handlers: authenticators}, []string{bootstrappolicy.AuthenticatedGroup}))
684+
topLevelAuthenticators = append(topLevelAuthenticators, anonymous.NewAuthenticator())
675685

676-
return ret, nil
686+
return &unionrequest.Authenticator{
687+
FailOnError: true,
688+
Handlers: topLevelAuthenticators,
689+
}, nil
677690
}
678691

679692
func newProjectAuthorizationCache(authorizer authorizer.Authorizer, kubeClient *kclientset.Clientset, informerFactory shared.InformerFactory) *projectauth.AuthorizationCache {

0 commit comments

Comments
 (0)