user.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. )
  18. const (
  19. PasswordResetHintAdminReset = "admin_reset"
  20. PasswordResetHintExpire = "expire"
  21. )
  22. type SUserGroup struct {
  23. Id string `json:"id"`
  24. Name string `json:"name"`
  25. Domain string `json:"domain"`
  26. DomainId string `json:"domain_id"`
  27. }
  28. type UserDetails struct {
  29. EnabledIdentityBaseResourceDetails
  30. // IdpResourceInfo
  31. SUser
  32. UserUsage
  33. // 归属该用户的外部资源统计信息
  34. ExternalResourceInfo
  35. // 用户归属的的项目信息
  36. Projects []SFetchDomainObjectWithMetadata `json:"projects"`
  37. // 用户归属的组
  38. Groups []SUserGroup `json:"groups"`
  39. }
  40. type UserUsage struct {
  41. // 用户归属用户组的数量
  42. GroupCount int `json:"group_count"`
  43. // 用户归属项目的数量
  44. ProjectCount int `json:"project_count"`
  45. // 归属该用户的密钥凭证(含AKSK,TOTP,Secret等)的数量
  46. CredentialCount int `json:"credential_count"`
  47. // 连续登录失败的次数
  48. FailedAuthCount int `json:"failed_auth_count"`
  49. // 上传登录失败的时间
  50. FailedAuthAt time.Time `json:"failed_auth_at"`
  51. // 登录后是否需要重置密码
  52. NeedResetPassword bool `json:"need_reset_password"`
  53. // 重置密码原因: admin_reset|expire
  54. PasswordResetHint string `json:"password_reset_hint"`
  55. // 密码过期时间(如果开启了密码过期)
  56. PasswordExpiresAt time.Time `json:"password_expires_at"`
  57. // 该用户是否为本地用户(SQL维护的用户)
  58. IsLocal bool `json:"is_local"`
  59. // 该用户关联的外部认证源的认证信息
  60. Idps []IdpResourceInfo `json:"idps"`
  61. }
  62. type ResetCredentialInput struct {
  63. // 密钥的类型
  64. Type string `json:"type"`
  65. }