user_auth.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package models
  2. import (
  3. "time"
  4. "golang.org/x/oauth2"
  5. )
  6. type UserAuth struct {
  7. Id int64
  8. UserId int64
  9. AuthModule string
  10. AuthId string
  11. Created time.Time
  12. OAuthAccessToken string
  13. OAuthRefreshToken string
  14. OAuthTokenType string
  15. OAuthExpiry time.Time
  16. }
  17. type ExternalUserInfo struct {
  18. OAuthToken *oauth2.Token
  19. AuthModule string
  20. AuthId string
  21. UserId int64
  22. Email string
  23. Login string
  24. Name string
  25. Groups []string
  26. OrgRoles map[int64]RoleType
  27. IsGrafanaAdmin *bool // This is a pointer to know if we should sync this or not (nil = ignore sync)
  28. }
  29. // ---------------------
  30. // COMMANDS
  31. type UpsertUserCommand struct {
  32. ReqContext *ReqContext
  33. ExternalUser *ExternalUserInfo
  34. SignupAllowed bool
  35. Result *User
  36. }
  37. type SetAuthInfoCommand struct {
  38. AuthModule string
  39. AuthId string
  40. UserId int64
  41. OAuthToken *oauth2.Token
  42. }
  43. type UpdateAuthInfoCommand struct {
  44. AuthModule string
  45. AuthId string
  46. UserId int64
  47. OAuthToken *oauth2.Token
  48. }
  49. type DeleteAuthInfoCommand struct {
  50. UserAuth *UserAuth
  51. }
  52. // ----------------------
  53. // QUERIES
  54. type LoginUserQuery struct {
  55. ReqContext *ReqContext
  56. Username string
  57. Password string
  58. User *User
  59. IpAddress string
  60. }
  61. type GetUserByAuthInfoQuery struct {
  62. AuthModule string
  63. AuthId string
  64. UserId int64
  65. Email string
  66. Login string
  67. Result *User
  68. }
  69. type GetAuthInfoQuery struct {
  70. UserId int64
  71. AuthModule string
  72. AuthId string
  73. Result *UserAuth
  74. }
  75. type SyncTeamsCommand struct {
  76. ExternalUser *ExternalUserInfo
  77. User *User
  78. }