Skip to content

Commit

Permalink
fix: gateway's http handler not configured properly and needs to igno…
Browse files Browse the repository at this point in the history
…re protected path
  • Loading branch information
choujimmy committed Feb 25, 2020
1 parent 9201991 commit 04d6ca3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions cmd/tke-gateway/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ package config
import (
"context"
"fmt"
"net/http"
"path/filepath"
"strings"

gooidc "github.com/coreos/go-oidc"
"golang.org/x/oauth2"
"k8s.io/apiserver/pkg/authentication/request/anonymous"
"k8s.io/apiserver/pkg/authorization/authorizerfactory"
genericapiserver "k8s.io/apiserver/pkg/server"
"net/http"
"path/filepath"
"strings"
"tkestack.io/tke/cmd/tke-gateway/app/options"
"tkestack.io/tke/pkg/apiserver"
"tkestack.io/tke/pkg/apiserver/authentication/authenticator/oidc"
Expand All @@ -55,6 +56,7 @@ type Config struct {
OIDCHTTPClient *http.Client
OIDCAuthenticator *oidc.Authenticator
GatewayConfig *gatewayconfig.GatewayConfiguration
IgnoreAuthPathPrefixes []string
}

// CreateConfigFromOptions creates a running configuration instance based
Expand Down Expand Up @@ -131,6 +133,7 @@ func CreateConfigFromOptions(serverName string, opts *options.Options) (*Config,
OIDCHTTPClient: oidcHTTPClient,
OIDCAuthenticator: oidcAuthenticator,
GatewayConfig: gatewayConfig,
IgnoreAuthPathPrefixes: ignoreAuthPathPrefixes,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/tke-gateway/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func CreateServerChain(cfg *config.Config, stopCh <-chan struct{}) (*genericapis
}

if cfg.InsecureServingInfo != nil {
chain := handler.BuildHandlerChain(nil)
chain := handler.BuildHandlerChain(cfg.IgnoreAuthPathPrefixes)
insecureHandlerChain := chain(gatewayServer.GenericAPIServer.UnprotectedHandler(), &gatewayConfig.GenericConfig.Config)
if err := cfg.InsecureServingInfo.Serve(insecureHandlerChain, gatewayConfig.GenericConfig.RequestTimeout, stopCh); err != nil {
return nil, err
Expand Down

0 comments on commit 04d6ca3

Please sign in to comment.