token.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package model
  2. import "iot_manager_service/app/user/dao"
  3. type Token struct {
  4. TenantId string
  5. UserName string
  6. Password string
  7. GrantType string
  8. RefreshToken string
  9. UserType string
  10. }
  11. type UserInfo struct {
  12. *dao.User //用户基础信息
  13. Permissions []string //权限标识集合
  14. Roles []string //角色集合
  15. OauthId string //第三方授权id
  16. }
  17. type RspToken struct {
  18. TenantId string `json:"tenant_id"`
  19. UserId string `json:"user_id"`
  20. DeptId string `json:"dept_id"`
  21. PostId string `json:"post_id"`
  22. RoleId string `json:"role_id"`
  23. OauthId string `json:"oauth_id"`
  24. Account string `json:"account"`
  25. UserName string `json:"user_name"`
  26. NickName string `json:"nick_name"`
  27. RoleName string `json:"role_name"`
  28. Avatar string `json:"avatar"`
  29. AccessToken string `json:"access_token"`
  30. RefreshToken string `json:"refresh_token"`
  31. TokenType string `json:"token_type"`
  32. ExpiresIn int `json:"expires_in"`
  33. License string `json:"license"`
  34. }
  35. // JWT
  36. const (
  37. Iss = "iss"
  38. Aud = "aud"
  39. TenantId = "tenant_id"
  40. RoleName = "role_name"
  41. PostId = "post_id"
  42. UserId = "user_id"
  43. RoleId = "role_id"
  44. UserName = "user_name"
  45. OauthID = "oauth_id"
  46. NickName = "nick_name"
  47. TokenType = "token_type"
  48. DeptId = "dept_id"
  49. Account = "account"
  50. ClientId = "client_id"
  51. Exp = "exp"
  52. Nbf = "nbf"
  53. BEARER = "bearer"
  54. )
  55. const (
  56. CAPTCHA_HEADER_KEY = "Captcha-Key"
  57. CAPTCHA_HEADER_CODE = "Captcha-Code"
  58. CAPTCHA_NOT_CORRECT = "验证码不正确"
  59. TENANT_HEADER_KEY = "Tenant-Id"
  60. DEFAULT_TENANT_ID = "000000"
  61. USER_TYPE_HEADER_KEY = "User-Type"
  62. DEFAULT_USER_TYPE = "web"
  63. USER_NOT_FOUND = "用户名或密码错误"
  64. USER_HAS_NO_ROLE = "未获得用户的角色信息"
  65. USER_HAS_NO_TENANT = "未获得用户的租户信息"
  66. USER_HAS_NO_TENANT_PERMISSION = "租户授权已过期,请联系管理员"
  67. HEADER_KEY = "Authorization"
  68. HEADER_PREFIX = "Basic "
  69. DEFAULT_AVATAR = "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"
  70. CAPTCHA_KEY = "blade:auth::blade:captcha:"
  71. )