saml.go 2.5 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. type SIdpAttributeOptions struct {
  16. DomainNameAttribute string `json:"domain_name_attribute"`
  17. DomainIdAttribute string `json:"domain_id_attribute"`
  18. UserNameAttribute string `json:"user_name_attribute"`
  19. UserIdAttribute string `json:"user_id_attribute"`
  20. UserDisplaynameAttribtue string `json:"user_displayname_attribute"`
  21. UserEmailAttribute string `json:"user_email_attribute"`
  22. UserMobileAttribute string `json:"user_mobile_attribute"`
  23. ProjectAttribute string `json:"project_attribute"`
  24. RolesAttribute string `json:"roles_attribute"`
  25. DefaultProjectId string `json:"default_project_id"`
  26. DefaultRoleId string `json:"default_role_id"`
  27. }
  28. type SSAMLIdpBaseConfigOptions struct {
  29. AllowIdpInit *bool `json:"allow_idp_init"`
  30. }
  31. type SSAMLIdpConfigOptions struct {
  32. EntityId string `json:"entity_id"`
  33. RedirectSSOUrl string `json:"redirect_sso_url"`
  34. SSAMLIdpBaseConfigOptions
  35. SIdpAttributeOptions
  36. }
  37. type SSAMLTestIdpConfigOptions struct {
  38. // empty
  39. SSAMLIdpBaseConfigOptions
  40. }
  41. type SSAMLAzureADConfigOptions struct {
  42. TenantId string `json:"tenant_id"`
  43. SSAMLIdpBaseConfigOptions
  44. SIdpAttributeOptions
  45. }
  46. func (a *SIdpAttributeOptions) Update(a2 SIdpAttributeOptions) {
  47. if len(a2.UserNameAttribute) > 0 {
  48. a.UserNameAttribute = a2.UserNameAttribute
  49. }
  50. if len(a2.UserIdAttribute) > 0 {
  51. a.UserIdAttribute = a2.UserIdAttribute
  52. }
  53. if len(a2.UserDisplaynameAttribtue) > 0 {
  54. a.UserDisplaynameAttribtue = a2.UserDisplaynameAttribtue
  55. }
  56. if len(a2.UserEmailAttribute) > 0 {
  57. a.UserEmailAttribute = a2.UserEmailAttribute
  58. }
  59. if len(a2.UserMobileAttribute) > 0 {
  60. a.UserMobileAttribute = a2.UserMobileAttribute
  61. }
  62. if len(a2.ProjectAttribute) > 0 {
  63. a.ProjectAttribute = a2.ProjectAttribute
  64. }
  65. if len(a2.RolesAttribute) > 0 {
  66. a.RolesAttribute = a2.RolesAttribute
  67. }
  68. if len(a2.DefaultProjectId) > 0 {
  69. a.DefaultProjectId = a2.DefaultProjectId
  70. }
  71. if len(a2.DefaultRoleId) > 0 {
  72. a.DefaultRoleId = a2.DefaultRoleId
  73. }
  74. }