rolepolicy.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package identity
  15. import (
  16. "time"
  17. "yunion.io/x/pkg/util/rbacscope"
  18. "yunion.io/x/onecloud/pkg/apis"
  19. "yunion.io/x/onecloud/pkg/util/rbacutils"
  20. )
  21. type RolePolicyListInput struct {
  22. apis.ResourceBaseListInput
  23. RoleIds []string `json:"role_ids"`
  24. ProjectId string `json:"project_id"`
  25. PolicyId string `json:"policy_id"`
  26. Auth *bool `json:"auth"`
  27. }
  28. type RolePolicyDetails struct {
  29. apis.ResourceBaseDetails
  30. Id string `json:"id"`
  31. Name string `json:"name"`
  32. Role string `json:"role"`
  33. Project string `json:"project"`
  34. Policy string `json:"policy"`
  35. Scope rbacscope.TRbacScope `json:"scope"`
  36. Description string `json:"description"`
  37. SRolePolicy
  38. }
  39. const (
  40. ROLE_SET_POLICY_ACTION_REPLACE = "replace"
  41. ROLE_SET_POLICY_ACTION_UPDATE = "update"
  42. ROLE_SET_POLICY_ACTION_DEFAULT = ROLE_SET_POLICY_ACTION_REPLACE
  43. )
  44. type RolePerformSetPoliciesInput struct {
  45. // 操作:replace|update, 默认为replace
  46. Action string `json:"action"`
  47. // 权限列表
  48. Policies []RolePerformAddPolicyInput `json:"policies"`
  49. }
  50. type RolePerformAddPolicyInput struct {
  51. PolicyId string `json:"policy_id"`
  52. ProjectId string `json:"project_id"`
  53. Ips []string `json:"ips"`
  54. ValidSince time.Time `json:"valid_since"`
  55. ValidUntil time.Time `json:"valid_until"`
  56. }
  57. type RolePerformRemovePolicyInput struct {
  58. PolicyId string `json:"policy_id"`
  59. ProjectId string `json:"project_id"`
  60. }
  61. type IRbacIdentityWithUserId interface {
  62. rbacutils.IRbacIdentity
  63. GetUserId() string
  64. }