Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(auth): add second auth check #2186

Merged
merged 1 commit into from
Dec 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/auth/filter/filter.go
Original file line number Diff line number Diff line change
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