Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
afcd0efe
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
afcd0efe
编写于
7月 26, 2020
作者:
K
KubeSphere CI Bot
提交者:
GitHub
7月 26, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2629 from wansir/authorizer
Reorder request filters
上级
c5a63500
f8c0e9ad
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
6 addition
and
138 deletion
+6
-138
pkg/apiserver/apiserver.go
pkg/apiserver/apiserver.go
+6
-8
pkg/apiserver/authorization/proxy/doc.go
pkg/apiserver/authorization/proxy/doc.go
+0
-17
pkg/apiserver/authorization/proxy/proxy.go
pkg/apiserver/authorization/proxy/proxy.go
+0
-33
pkg/apiserver/authorization/proxy/proxy_test.go
pkg/apiserver/authorization/proxy/proxy_test.go
+0
-80
未找到文件。
pkg/apiserver/apiserver.go
浏览文件 @
afcd0efe
...
...
@@ -41,7 +41,6 @@ import (
"kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizerfactory"
authorizationoptions
"kubesphere.io/kubesphere/pkg/apiserver/authorization/options"
"kubesphere.io/kubesphere/pkg/apiserver/authorization/path"
"kubesphere.io/kubesphere/pkg/apiserver/authorization/proxy"
unionauthorizer
"kubesphere.io/kubesphere/pkg/apiserver/authorization/union"
apiserverconfig
"kubesphere.io/kubesphere/pkg/apiserver/config"
"kubesphere.io/kubesphere/pkg/apiserver/dispatch"
...
...
@@ -265,12 +264,6 @@ func (s *APIServer) buildHandlerChain(stopCh <-chan struct{}) {
s
.
Config
.
AuditingOptions
.
WebhookUrl
,
stopCh
))
}
if
s
.
Config
.
MultiClusterOptions
.
Enable
{
clusterDispatcher
:=
dispatch
.
NewClusterDispatch
(
s
.
InformerFactory
.
KubeSphereSharedInformerFactory
()
.
Cluster
()
.
V1alpha1
()
.
Clusters
(),
s
.
InformerFactory
.
KubeSphereSharedInformerFactory
()
.
Cluster
()
.
V1alpha1
()
.
Clusters
()
.
Lister
())
handler
=
filters
.
WithMultipleClusterDispatcher
(
handler
,
clusterDispatcher
)
}
var
authorizers
authorizer
.
Authorizer
switch
s
.
Config
.
AuthorizationOptions
.
Mode
{
...
...
@@ -284,10 +277,15 @@ func (s *APIServer) buildHandlerChain(stopCh <-chan struct{}) {
excludedPaths
:=
[]
string
{
"/oauth/*"
,
"/kapis/config.kubesphere.io/*"
,
"/kapis/version"
}
pathAuthorizer
,
_
:=
path
.
NewAuthorizer
(
excludedPaths
)
amOperator
:=
am
.
NewReadOnlyOperator
(
s
.
InformerFactory
)
authorizers
=
unionauthorizer
.
New
(
pathAuthorizer
,
proxy
.
NewAuthorizer
(
s
.
Config
.
MultiClusterOptions
.
Enable
),
authorizerfactory
.
NewRBACAuthorizer
(
amOperator
))
authorizers
=
unionauthorizer
.
New
(
pathAuthorizer
,
authorizerfactory
.
NewRBACAuthorizer
(
amOperator
))
}
handler
=
filters
.
WithAuthorization
(
handler
,
authorizers
)
if
s
.
Config
.
MultiClusterOptions
.
Enable
{
clusterDispatcher
:=
dispatch
.
NewClusterDispatch
(
s
.
InformerFactory
.
KubeSphereSharedInformerFactory
()
.
Cluster
()
.
V1alpha1
()
.
Clusters
(),
s
.
InformerFactory
.
KubeSphereSharedInformerFactory
()
.
Cluster
()
.
V1alpha1
()
.
Clusters
()
.
Lister
())
handler
=
filters
.
WithMultipleClusterDispatcher
(
handler
,
clusterDispatcher
)
}
loginRecorder
:=
im
.
NewLoginRecorder
(
s
.
KubernetesClient
.
KubeSphere
())
// authenticators are unordered
...
...
pkg/apiserver/authorization/proxy/doc.go
已删除
100644 → 0
浏览文件 @
c5a63500
/*
Copyright 2020 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
proxy
pkg/apiserver/authorization/proxy/proxy.go
已删除
100644 → 0
浏览文件 @
c5a63500
/*
Copyright 2020 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
proxy
import
(
"kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizer"
)
// NewAuthorizer returns an authorizer which accepts cluster proxy request.
// If multi-cluster mode is enabled, request should authorize by target apiserver.
func
NewAuthorizer
(
multiClusterEnabled
bool
)
authorizer
.
Authorizer
{
return
authorizer
.
AuthorizerFunc
(
func
(
a
authorizer
.
Attributes
)
(
authorizer
.
Decision
,
string
,
error
)
{
// in multi cluster mode, the request will be dispatch.
if
multiClusterEnabled
&&
a
.
GetCluster
()
!=
""
{
return
authorizer
.
DecisionAllow
,
""
,
nil
}
return
authorizer
.
DecisionNoOpinion
,
""
,
nil
})
}
pkg/apiserver/authorization/proxy/proxy_test.go
已删除
100644 → 0
浏览文件 @
c5a63500
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
proxy
import
(
"kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizer"
"testing"
)
func
TestNewAuthorizer
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
multiClusterEnabled
bool
request
authorizer
.
AttributesRecord
expectResult
authorizer
.
Decision
}{
{
multiClusterEnabled
:
false
,
request
:
authorizer
.
AttributesRecord
{
Workspace
:
"ws"
,
Namespace
:
"ns"
,
KubernetesRequest
:
false
,
ResourceRequest
:
false
,
},
expectResult
:
authorizer
.
DecisionNoOpinion
,
},
{
multiClusterEnabled
:
false
,
request
:
authorizer
.
AttributesRecord
{
Cluster
:
"cluster1"
,
Workspace
:
"ws"
,
Namespace
:
"ns"
,
KubernetesRequest
:
false
,
ResourceRequest
:
false
,
},
expectResult
:
authorizer
.
DecisionNoOpinion
,
},
{
multiClusterEnabled
:
true
,
request
:
authorizer
.
AttributesRecord
{
Cluster
:
"cluster1"
,
Workspace
:
"ws"
,
Namespace
:
"ns"
,
KubernetesRequest
:
false
,
ResourceRequest
:
false
,
},
expectResult
:
authorizer
.
DecisionAllow
,
},
{
multiClusterEnabled
:
true
,
request
:
authorizer
.
AttributesRecord
{
Workspace
:
"ws"
,
Namespace
:
"ns"
,
KubernetesRequest
:
false
,
ResourceRequest
:
false
,
},
expectResult
:
authorizer
.
DecisionNoOpinion
,
},
}
for
i
,
test
:=
range
tests
{
a
:=
NewAuthorizer
(
test
.
multiClusterEnabled
)
result
,
_
,
_
:=
a
.
Authorize
(
test
.
request
)
if
result
!=
test
.
expectResult
{
t
.
Errorf
(
"case %d, got %#v, expected %#v"
,
i
,
result
,
test
.
expectResult
)
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录