4665dc253f
* WIP: Fix XSS in runbook URL (#378) (cherry picked from commit f4a8d96a4e1259ea25d9cc702a652f1b819db236) (cherry picked from commit 337c08507b2b1c78ea470192d34cf611fae4b5da) (cherry picked from commit 54b36a07406ed4e26ff8e161e50eda5401f504da) * Update grabpl version (cherry picked from commit b253e87d730f7b8aabdd0b328c5e7a82547c43b3) (cherry picked from commit 080d3e46f3fcd61555795b9fe8fd6ee2492b422a) * Fix: Choose Lookup params per auth module Co-authored-by: Karl Persson <kalle.persson@grafana.com> Fix: Prefer pointer to struct in lookup Co-authored-by: Karl Persson <kalle.persson@grafana.com> Fix: user email for ldap Co-authored-by: Karl Persson <kalle.persson@grafana.com> Fix: Use only login for lookup in LDAP Co-authored-by: Karl Persson <kalle.persson@grafana.com> Fix: use user email for ldap Co-authored-by: Karl Persson <kalle.persson@grafana.com> fix remaining test fix nit picks (cherry picked from commit 1eca4aeed878853743cebcf9790b05dd350c4f83) (cherry picked from commit 0777d100e9263d08f51dbac71aee0766c8a85a92) * remove better (broke the pipeline) Co-authored-by: George Robinson <george.robinson@grafana.com> Co-authored-by: dsotirakis <sotirakis.dim@gmail.com> Co-authored-by: jguer <joao.guerreiro@grafana.com>
128 lines
2.4 KiB
Go
128 lines
2.4 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"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
|
|
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
|
|
UserLookupParams
|
|
Result *User
|
|
SignupAllowed bool
|
|
}
|
|
|
|
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
|
|
AuthModule string
|
|
Cfg *setting.Cfg
|
|
}
|
|
|
|
type GetUserByAuthInfoQuery struct {
|
|
AuthModule string
|
|
AuthId string
|
|
UserLookupParams
|
|
}
|
|
|
|
type UserLookupParams struct {
|
|
// Describes lookup order as well
|
|
UserID *int64 // if set, will try to find the user by id
|
|
Email *string // if set, will try to find the user by email
|
|
Login *string // if set, will try to find the user by login
|
|
}
|
|
|
|
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"`
|
|
}
|