Skip to content

Commit be2d5ff

Browse files
committed
remove unneeded parameter since we're now relying on the context
On-behalf-of: @SAP [email protected]
1 parent d247b51 commit be2d5ff

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

pkg/authentication/filters.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import (
2525
"github.com/kcp-dev/kcp/pkg/proxy/lookup"
2626
)
2727

28-
// WithWorkspaceAuthentication looks up the target cluster in the given auth index
28+
// WithWorkspaceAuthResolver looks up the target cluster in the given auth index
2929
// to populate a possible workspace authenticator in the request's context. This
3030
// is used to let other middlewares know about the existence of additional auth
3131
// options.
32-
func WithWorkspaceAuthentication(handler http.Handler, authIndex AuthenticatorIndex) http.Handler {
32+
func WithWorkspaceAuthResolver(handler http.Handler, authIndex AuthenticatorIndex) http.Handler {
3333
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
3434
wsType := lookup.WorkspaceTypeFrom(req.Context())
3535
if wsType.Empty() {

pkg/authentication/workspace.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,10 @@ import (
2222
"k8s.io/apiserver/pkg/authentication/authenticator"
2323
)
2424

25-
type workspaceAuthenticator struct {
26-
authIndex AuthenticatorIndex
27-
}
25+
type workspaceAuthenticator struct{}
2826

29-
func NewWorkspaceAuthenticator(authIndex AuthenticatorIndex) authenticator.Request {
30-
return &workspaceAuthenticator{
31-
authIndex: authIndex,
32-
}
27+
func NewWorkspaceAuthenticator() authenticator.Request {
28+
return &workspaceAuthenticator{}
3329
}
3430

3531
func (a *workspaceAuthenticator) AuthenticateRequest(req *http.Request) (*authenticator.Response, bool, error) {

pkg/proxy/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func NewServer(ctx context.Context, c CompletedConfig) (*Server, error) {
121121
// a custom authenticator exists or not. This needs to be determined before
122122
// the optionalAuthentication middleware can run, as it needs to know about
123123
// the workspace authenticator.
124-
handler = authentication.WithWorkspaceAuthentication(handler, s.AuthController)
124+
handler = authentication.WithWorkspaceAuthResolver(handler, s.AuthController)
125125
}
126126

127127
if hasShardMapping {

pkg/server/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ func NewConfig(ctx context.Context, opts kcpserveroptions.CompletedOptions) (*Co
470470

471471
genericConfig.Authentication.Authenticator = authenticatorunion.New(
472472
genericConfig.Authentication.Authenticator,
473-
authentication.NewWorkspaceAuthenticator(authIndexState),
473+
authentication.NewWorkspaceAuthenticator(),
474474
)
475475

476476
authIndex = authIndexState
@@ -491,7 +491,7 @@ func NewConfig(ctx context.Context, opts kcpserveroptions.CompletedOptions) (*Co
491491
// the authentication middleware can run, as it needs to know about the
492492
// workspace authenticator.
493493
if kcpfeatures.DefaultFeatureGate.Enabled(kcpfeatures.WorkspaceAuthentication) {
494-
apiHandler = authentication.WithWorkspaceAuthentication(apiHandler, authIndex)
494+
apiHandler = authentication.WithWorkspaceAuthResolver(apiHandler, authIndex)
495495
}
496496

497497
// this will be replaced in DefaultBuildHandlerChain. So at worst we get twice as many warning.

0 commit comments

Comments
 (0)