mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #447 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:hotfix/qj-policy-admin-capable-test to release/2.3.0
* commit 'dbab380d734d0de1684f5cb4472869d5d981d773': 增加climc policy-admin-capable命令
This commit is contained in:
@@ -184,6 +184,18 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type PolicyAdminCapableOptions struct {
|
||||
}
|
||||
R(&PolicyAdminCapableOptions{}, "policy-admin-capable", "Check admin capable", func(s *mcclient.ClientSession, args *PolicyAdminCapableOptions) error {
|
||||
auth.InitFromClientSession(s)
|
||||
policy.EnableGlobalRbac(15*time.Second, 15*time.Second)
|
||||
|
||||
capable := policy.PolicyManager.IsAdminCapable(s.GetToken())
|
||||
fmt.Printf("%v\n", capable)
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
type PolicyExplainOptions struct {
|
||||
Request []string `help:"explain request, in format of key:is_admin:service:resource:action:extra"`
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
)
|
||||
|
||||
func EnableGlobalRbac(refreshInterval time.Duration, retryInterval time.Duration) {
|
||||
consts.EnableRbac()
|
||||
PolicyManager.start(refreshInterval, retryInterval)
|
||||
if !consts.IsRbacEnabled() {
|
||||
consts.EnableRbac()
|
||||
PolicyManager.start(refreshInterval, retryInterval)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user