2018-02-08 16:13:58 -06:00
|
|
|
package models
|
|
|
|
|
2018-03-19 16:09:49 -05:00
|
|
|
import (
|
|
|
|
"time"
|
2019-02-01 18:40:57 -06:00
|
|
|
|
|
|
|
"golang.org/x/oauth2"
|
2018-03-19 16:09:49 -05:00
|
|
|
)
|
|
|
|
|
2019-05-21 06:52:49 -05:00
|
|
|
const (
|
|
|
|
AuthModuleLDAP = "ldap"
|
|
|
|
)
|
|
|
|
|
2018-02-08 16:13:58 -06:00
|
|
|
type UserAuth struct {
|
2019-02-01 18:40:57 -06:00
|
|
|
Id int64
|
|
|
|
UserId int64
|
|
|
|
AuthModule string
|
|
|
|
AuthId string
|
|
|
|
Created time.Time
|
|
|
|
OAuthAccessToken string
|
|
|
|
OAuthRefreshToken string
|
|
|
|
OAuthTokenType string
|
|
|
|
OAuthExpiry time.Time
|
2018-02-08 16:13:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type ExternalUserInfo struct {
|
2019-02-01 18:40:57 -06:00
|
|
|
OAuthToken *oauth2.Token
|
2018-07-16 09:56:42 -05:00
|
|
|
AuthModule string
|
|
|
|
AuthId string
|
|
|
|
UserId int64
|
|
|
|
Email string
|
|
|
|
Login string
|
|
|
|
Name string
|
|
|
|
Groups []string
|
|
|
|
OrgRoles map[int64]RoleType
|
|
|
|
IsGrafanaAdmin *bool // This is a pointer to know if we should sync this or not (nil = ignore sync)
|
2019-05-21 06:52:49 -05:00
|
|
|
IsDisabled bool
|
2018-02-08 16:13:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------
|
|
|
|
// COMMANDS
|
|
|
|
|
|
|
|
type UpsertUserCommand struct {
|
2018-03-23 14:50:07 -05:00
|
|
|
ReqContext *ReqContext
|
2018-02-08 16:13:58 -06:00
|
|
|
ExternalUser *ExternalUserInfo
|
|
|
|
SignupAllowed bool
|
|
|
|
|
2018-03-23 10:16:11 -05:00
|
|
|
Result *User
|
2018-02-08 16:13:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type SetAuthInfoCommand struct {
|
|
|
|
AuthModule string
|
|
|
|
AuthId string
|
|
|
|
UserId int64
|
2019-02-01 18:40:57 -06:00
|
|
|
OAuthToken *oauth2.Token
|
|
|
|
}
|
|
|
|
|
|
|
|
type UpdateAuthInfoCommand struct {
|
|
|
|
AuthModule string
|
|
|
|
AuthId string
|
|
|
|
UserId int64
|
|
|
|
OAuthToken *oauth2.Token
|
2018-02-08 16:13:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type DeleteAuthInfoCommand struct {
|
|
|
|
UserAuth *UserAuth
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------
|
|
|
|
// QUERIES
|
|
|
|
|
|
|
|
type LoginUserQuery struct {
|
2018-03-23 14:50:07 -05:00
|
|
|
ReqContext *ReqContext
|
|
|
|
Username string
|
|
|
|
Password string
|
|
|
|
User *User
|
|
|
|
IpAddress string
|
2018-02-08 16:13:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type GetUserByAuthInfoQuery struct {
|
|
|
|
AuthModule string
|
|
|
|
AuthId string
|
|
|
|
UserId int64
|
|
|
|
Email string
|
|
|
|
Login string
|
|
|
|
|
2018-03-28 20:26:35 -05:00
|
|
|
Result *User
|
2018-02-08 16:13:58 -06:00
|
|
|
}
|
|
|
|
|
2019-05-21 06:52:49 -05:00
|
|
|
type GetExternalUserInfoByLoginQuery struct {
|
|
|
|
LoginOrEmail string
|
|
|
|
|
|
|
|
Result *ExternalUserInfo
|
|
|
|
}
|
|
|
|
|
2018-02-08 16:13:58 -06:00
|
|
|
type GetAuthInfoQuery struct {
|
2019-02-01 18:40:57 -06:00
|
|
|
UserId int64
|
2018-02-08 16:13:58 -06:00
|
|
|
AuthModule string
|
|
|
|
AuthId string
|
|
|
|
|
2018-03-28 17:06:22 -05:00
|
|
|
Result *UserAuth
|
2018-02-08 16:13:58 -06:00
|
|
|
}
|
2018-07-01 09:01:43 -05:00
|
|
|
|
2019-09-08 05:48:47 -05:00
|
|
|
type TeamOrgGroupDTO struct {
|
|
|
|
TeamName string `json:"teamName"`
|
|
|
|
OrgName string `json:"orgName"`
|
|
|
|
GroupDN string `json:"groupDN"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type GetTeamsForLDAPGroupCommand struct {
|
|
|
|
Groups []string
|
|
|
|
Result []TeamOrgGroupDTO
|
|
|
|
}
|
|
|
|
|
2018-07-01 09:01:43 -05:00
|
|
|
type SyncTeamsCommand struct {
|
|
|
|
ExternalUser *ExternalUserInfo
|
|
|
|
User *User
|
|
|
|
}
|