Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 069c30c

Browse files
committed
Merge pull request #15 from carmark/list_bug
add admin's username into white list instead of tenant
2 parents 6704083 + 061b7cc commit 069c30c

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

pkg/api/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ type ObjectMeta struct {
144144
}
145145

146146
const (
147-
// TenantAdmin
148-
TenantAdmin string = "admin"
147+
// UserAdmin the username of the administrator
148+
UserAdmin string = "admin"
149149
// TenantDefault
150150
TenantDefault string = "default"
151151
// TenantAll is the default argument to specify on a context when you want to list or filter resources across all tenants

pkg/apiserver/resthandler.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
281281
}
282282
//
283283
url := req.Request.URL.String()
284-
if strings.Index(url, "https://") == 0 {
284+
userinfo, _ := api.UserFrom(ctx)
285+
if strings.Index(url, "https://") == 0 && userinfo.GetName() != api.UserAdmin {
285286
tenant := api.TenantValue(ctx)
286287
if err := filterListInTenant(result, tenant, scope.Kind, scope.Namer); err != nil {
287288
errorJSON(err, scope.Codec, w)
@@ -833,9 +834,6 @@ func filterListInTenant(obj runtime.Object, tenant string, kind string, namer Sc
833834
if !runtime.IsListType(obj) {
834835
return nil
835836
}
836-
if tenant == api.TenantAdmin {
837-
return nil
838-
}
839837

840838
// Set self-link of objects in the list.
841839
items, err := runtime.ExtractList(obj)

pkg/auth/authorizer/keystone/keystone.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func (ka *keystoneAuthorizer) Authorize(a authorizer.Attributes) (string, error)
143143

144144
func isWhiteListedUser(username string) bool {
145145
whiteList := map[string]bool{
146+
api.UserAdmin: true,
146147
"kubelet": true,
147148
"kube_proxy": true,
148149
"system:scheduler": true,

0 commit comments

Comments
 (0)