Skip to content

Commit

Permalink
fix(auth): add second auth check (#2186)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo Ryu committed Dec 5, 2022
1 parent 4a7e990 commit 4eebafd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/auth/filter/filter.go
Expand Up @@ -24,9 +24,10 @@ import (
"net/http/httputil"
"strconv"
"strings"
genericoidc "tkestack.io/tke/pkg/apiserver/authentication/authenticator/oidc"
"unicode"

genericoidc "tkestack.io/tke/pkg/apiserver/authentication/authenticator/oidc"

"github.com/go-openapi/inflect"
"golang.org/x/net/context"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -156,6 +157,11 @@ func WithTKEAuthorization(handler http.Handler, a authorizer.Authorizer, s runti

// firstly check if resource is unprotected
authorized = UnprotectedAuthorized(attributes)
if authorized != authorizer.DecisionAllow {
authorized, reason, err = a.Authorize(ctx, attributes)
}

// secondly check k8s resource authz result
if authorized != authorizer.DecisionAllow {
if tenantID != "" {
log.Debugf("TKEStack user '%v'", attributes.GetUser())
Expand Down

0 comments on commit 4eebafd

Please sign in to comment.