Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
6585881d
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6585881d
编写于
7月 24, 2020
作者:
W
wanjunlei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug multi tenant auditing, logging and event is incorrect
Signed-off-by:
N
wanjunlei
<
wanjunlei@yunify.com
>
上级
06932926
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
11 deletion
+32
-11
pkg/models/tenant/tenant.go
pkg/models/tenant/tenant.go
+32
-11
未找到文件。
pkg/models/tenant/tenant.go
浏览文件 @
6585881d
...
...
@@ -558,11 +558,10 @@ func (t *tenantOperator) DeleteWorkspace(workspace string) error {
}
// listIntersectedNamespaces lists the namespaces which meet all the following conditions at the same time
// 1. the namespace which belongs to user.
// 2. the namespace in workspace which is in workspaces when workspaces is not empty.
// 3. the namespace in workspace which contains one of workspaceSubstrs when workspaceSubstrs is not empty.
// 4. the namespace which is in namespaces when namespaces is not empty.
// 5. the namespace which contains one of namespaceSubstrs when namespaceSubstrs is not empty.
// 1. the namespace in workspace which is in workspaces when workspaces is not empty.
// 2. the namespace in workspace which contains one of workspaceSubstrs when workspaceSubstrs is not empty.
// 3. the namespace which is in namespaces when namespaces is not empty.
// 4. the namespace which contains one of namespaceSubstrs when namespaceSubstrs is not empty.
func
(
t
*
tenantOperator
)
listIntersectedNamespaces
(
user
user
.
Info
,
workspaces
,
workspaceSubstrs
,
namespaces
,
namespaceSubstrs
[]
string
)
([]
*
corev1
.
Namespace
,
error
)
{
var
(
...
...
@@ -573,7 +572,7 @@ func (t *tenantOperator) listIntersectedNamespaces(user user.Info,
)
includeNsWithoutWs
:=
len
(
workspaceSet
)
==
0
&&
len
(
workspaceSubstrs
)
==
0
result
,
err
:=
t
.
ListNamespaces
(
user
,
""
,
query
.
New
())
result
,
err
:=
t
.
resourceGetter
.
List
(
"namespaces"
,
""
,
query
.
New
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -806,21 +805,43 @@ func (t *tenantOperator) Auditing(user user.Info, queryParam *auditingv1alpha1.Q
}
namespaceCreateTimeMap
:=
make
(
map
[
string
]
time
.
Time
)
// Now auditing and event have the same authority management, so we can determine whether the user
// has permission to view the auditing log in ns by judging whether the user has the permission to view the event in ns.
for
_
,
ns
:=
range
iNamespaces
{
namespaceCreateTimeMap
[
ns
.
Name
]
=
ns
.
CreationTimestamp
.
Time
listEvts
:=
authorizer
.
AttributesRecord
{
User
:
user
,
Verb
:
"list"
,
APIGroup
:
""
,
APIVersion
:
"v1"
,
Namespace
:
ns
.
Name
,
Resource
:
"events"
,
ResourceRequest
:
true
,
ResourceScope
:
request
.
NamespaceScope
,
}
decision
,
_
,
err
:=
t
.
authorizer
.
Authorize
(
listEvts
)
if
err
!=
nil
{
klog
.
Error
(
err
)
return
nil
,
err
}
if
decision
==
authorizer
.
DecisionAllow
{
namespaceCreateTimeMap
[
ns
.
Name
]
=
ns
.
CreationTimestamp
.
Time
}
}
// If there are no ns and ws query conditions,
// those events with empty `
ObjectRef.Namespace` will also be listed when user can list all namespace
s
// those events with empty `
objectRef.namespace` will also be listed when user can list all event
s
if
len
(
queryParam
.
WorkspaceFilter
)
==
0
&&
len
(
queryParam
.
ObjectRefNamespaceFilter
)
==
0
&&
len
(
queryParam
.
WorkspaceSearch
)
==
0
&&
len
(
queryParam
.
ObjectRefNamespaceSearch
)
==
0
{
list
N
s
:=
authorizer
.
AttributesRecord
{
list
Evt
s
:=
authorizer
.
AttributesRecord
{
User
:
user
,
Verb
:
"list"
,
Resource
:
"namespaces"
,
APIGroup
:
""
,
APIVersion
:
"v1"
,
Resource
:
"events"
,
ResourceRequest
:
true
,
ResourceScope
:
request
.
ClusterScope
,
}
decision
,
_
,
err
:=
t
.
authorizer
.
Authorize
(
list
N
s
)
decision
,
_
,
err
:=
t
.
authorizer
.
Authorize
(
list
Evt
s
)
if
err
!=
nil
{
klog
.
Error
(
err
)
return
nil
,
err
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录