grafana/pkg/models/user_auth.go

118 lines
2.0 KiB
Go
Raw Normal View History

package models
2018-03-19 16:09:49 -05:00
import (
"time"
"golang.org/x/oauth2"
2018-03-19 16:09:49 -05:00
)
const (
AuthModuleLDAP = "ldap"
)
type UserAuth struct {
Id int64
UserId int64
AuthModule string
AuthId string
Created time.Time
OAuthAccessToken string
OAuthRefreshToken string
OAuthTokenType string
OAuthExpiry time.Time
}
type ExternalUserInfo struct {
OAuthToken *oauth2.Token
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)
IsDisabled bool
}
// ---------------------
// COMMANDS
type UpsertUserCommand struct {
ReqContext *ReqContext
ExternalUser *ExternalUserInfo
SignupAllowed bool
2018-03-23 10:16:11 -05:00
Result *User
}
type SetAuthInfoCommand struct {
AuthModule string
AuthId string
UserId int64
OAuthToken *oauth2.Token
}
type UpdateAuthInfoCommand struct {
AuthModule string
AuthId string
UserId int64
OAuthToken *oauth2.Token
}
type DeleteAuthInfoCommand struct {
UserAuth *UserAuth
}
// ----------------------
// QUERIES
type LoginUserQuery struct {
ReqContext *ReqContext
Username string
Password string
User *User
IpAddress string
}
type GetUserByAuthInfoQuery struct {
AuthModule string
AuthId string
UserId int64
Email string
Login string
2018-03-28 20:26:35 -05:00
Result *User
}
type GetExternalUserInfoByLoginQuery struct {
LoginOrEmail string
Result *ExternalUserInfo
}
type GetAuthInfoQuery struct {
UserId int64
AuthModule string
AuthId string
2018-03-28 17:06:22 -05:00
Result *UserAuth
}
type TeamOrgGroupDTO struct {
TeamName string `json:"teamName"`
OrgName string `json:"orgName"`
GroupDN string `json:"groupDN"`
}
type GetTeamsForLDAPGroupCommand struct {
Groups []string
Result []TeamOrgGroupDTO
}
type SyncTeamsCommand struct {
ExternalUser *ExternalUserInfo
User *User
}