mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Split Create User * Use new create user and User from package user * Add service to wire * Making create user work * Replace user from user pkg * One more * Move Insert to orguser Service/Store * Remove unnecessary conversion * Cleaunp * Fix Get User and add fakes * Fixing get org id for user logic, adding fakes and other adjustments * Add some tests for ourguser service and store * Fix insert org logic * Add comment about deprecation * Fix after merge with main * Move orguser service/store to org service/store * Remove orguser from wire * Unimplement new Create user and use User from pkg user * Fix wire generation * Fix lint * Fix lint - use only User and CrateUserCommand from user pkg * Remove User and CreateUserCommand from models * Fix lint 2
125 lines
2.3 KiB
Go
125 lines
2.3 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/grafana/grafana/pkg/services/user"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
|
|
"golang.org/x/oauth2"
|
|
)
|
|
|
|
const (
|
|
AuthModuleLDAP = "ldap"
|
|
)
|
|
|
|
type UserAuth struct {
|
|
Id int64
|
|
UserId int64
|
|
AuthModule string
|
|
AuthId string
|
|
Created time.Time
|
|
OAuthAccessToken string
|
|
OAuthRefreshToken string
|
|
OAuthIdToken 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
|
|
}
|
|
|
|
type LoginInfo struct {
|
|
AuthModule string
|
|
User *user.User
|
|
ExternalUser ExternalUserInfo
|
|
LoginUsername string
|
|
HTTPStatus int
|
|
Error error
|
|
}
|
|
|
|
// RequestURIKey is used as key to save request URI in contexts
|
|
// (used for the Enterprise auditing feature)
|
|
type RequestURIKey struct{}
|
|
|
|
// ---------------------
|
|
// COMMANDS
|
|
|
|
type UpsertUserCommand struct {
|
|
ReqContext *ReqContext
|
|
ExternalUser *ExternalUserInfo
|
|
SignupAllowed bool
|
|
|
|
Result *user.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.User
|
|
IpAddress string
|
|
AuthModule string
|
|
Cfg *setting.Cfg
|
|
}
|
|
|
|
type GetUserByAuthInfoQuery struct {
|
|
AuthModule string
|
|
AuthId string
|
|
UserId int64
|
|
Email string
|
|
Login string
|
|
}
|
|
|
|
type GetExternalUserInfoByLoginQuery struct {
|
|
LoginOrEmail string
|
|
|
|
Result *ExternalUserInfo
|
|
}
|
|
|
|
type GetAuthInfoQuery struct {
|
|
UserId int64
|
|
AuthModule string
|
|
AuthId string
|
|
|
|
Result *UserAuth
|
|
}
|
|
|
|
type TeamOrgGroupDTO struct {
|
|
TeamName string `json:"teamName"`
|
|
OrgName string `json:"orgName"`
|
|
GroupDN string `json:"groupDN"`
|
|
}
|