mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
User: Expose GCOM user ID as externalUserId in grafanaBootData (#47307)
* user essentials mob! 🔱 * user essentials mob! 🔱 * user essentials mob! 🔱 * user essentials mob! 🔱 * user essentials mob! 🔱 * fix sql indtent Co-authored-by: Joao Silva <joao.silva@grafana.com> Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
parent
05098ec38e
commit
71db5115f4
@ -28,6 +28,7 @@ type LoginCommand struct {
|
|||||||
type CurrentUser struct {
|
type CurrentUser struct {
|
||||||
IsSignedIn bool `json:"isSignedIn"`
|
IsSignedIn bool `json:"isSignedIn"`
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
|
ExternalUserId string `json:"externalUserId"`
|
||||||
Login string `json:"login"`
|
Login string `json:"login"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
@ -653,6 +653,7 @@ func (hs *HTTPServer) setIndexViewData(c *models.ReqContext) (*dtos.IndexViewDat
|
|||||||
IsSignedIn: c.IsSignedIn,
|
IsSignedIn: c.IsSignedIn,
|
||||||
Login: c.Login,
|
Login: c.Login,
|
||||||
Email: c.Email,
|
Email: c.Email,
|
||||||
|
ExternalUserId: c.SignedInUser.ExternalAuthId,
|
||||||
Name: c.Name,
|
Name: c.Name,
|
||||||
OrgCount: c.OrgCount,
|
OrgCount: c.OrgCount,
|
||||||
OrgId: c.OrgId,
|
OrgId: c.OrgId,
|
||||||
|
@ -169,20 +169,22 @@ type GetUserOrgListQuery struct {
|
|||||||
// DTO & Projections
|
// DTO & Projections
|
||||||
|
|
||||||
type SignedInUser struct {
|
type SignedInUser struct {
|
||||||
UserId int64
|
UserId int64
|
||||||
OrgId int64
|
OrgId int64
|
||||||
OrgName string
|
OrgName string
|
||||||
OrgRole RoleType
|
OrgRole RoleType
|
||||||
Login string
|
ExternalAuthModule string
|
||||||
Name string
|
ExternalAuthId string
|
||||||
Email string
|
Login string
|
||||||
ApiKeyId int64
|
Name string
|
||||||
OrgCount int
|
Email string
|
||||||
IsGrafanaAdmin bool
|
ApiKeyId int64
|
||||||
IsAnonymous bool
|
OrgCount int
|
||||||
HelpFlags1 HelpFlags1
|
IsGrafanaAdmin bool
|
||||||
LastSeenAt time.Time
|
IsAnonymous bool
|
||||||
Teams []int64
|
HelpFlags1 HelpFlags1
|
||||||
|
LastSeenAt time.Time
|
||||||
|
Teams []int64
|
||||||
// Permissions grouped by orgID and actions
|
// Permissions grouped by orgID and actions
|
||||||
Permissions map[int64]map[string][]string `json:"-"`
|
Permissions map[int64]map[string][]string `json:"-"`
|
||||||
}
|
}
|
||||||
|
@ -540,18 +540,21 @@ func (ss *SQLStore) GetSignedInUser(ctx context.Context, query *models.GetSigned
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rawSQL = `SELECT
|
var rawSQL = `SELECT
|
||||||
u.id as user_id,
|
u.id as user_id,
|
||||||
u.is_admin as is_grafana_admin,
|
u.is_admin as is_grafana_admin,
|
||||||
u.email as email,
|
u.email as email,
|
||||||
u.login as login,
|
u.login as login,
|
||||||
u.name as name,
|
u.name as name,
|
||||||
u.help_flags1 as help_flags1,
|
u.help_flags1 as help_flags1,
|
||||||
u.last_seen_at as last_seen_at,
|
u.last_seen_at as last_seen_at,
|
||||||
(SELECT COUNT(*) FROM org_user where org_user.user_id = u.id) as org_count,
|
(SELECT COUNT(*) FROM org_user where org_user.user_id = u.id) as org_count,
|
||||||
org.name as org_name,
|
user_auth.auth_module as external_auth_module,
|
||||||
org_user.role as org_role,
|
user_auth.auth_id as external_auth_id,
|
||||||
org.id as org_id
|
org.name as org_name,
|
||||||
|
org_user.role as org_role,
|
||||||
|
org.id as org_id
|
||||||
FROM ` + dialect.Quote("user") + ` as u
|
FROM ` + dialect.Quote("user") + ` as u
|
||||||
|
LEFT OUTER JOIN user_auth on user_auth.user_id = u.id
|
||||||
LEFT OUTER JOIN org_user on org_user.org_id = ` + orgId + ` and org_user.user_id = u.id
|
LEFT OUTER JOIN org_user on org_user.org_id = ` + orgId + ` and org_user.user_id = u.id
|
||||||
LEFT OUTER JOIN org on org.id = org_user.org_id `
|
LEFT OUTER JOIN org on org.id = org_user.org_id `
|
||||||
|
|
||||||
@ -579,6 +582,10 @@ func (ss *SQLStore) GetSignedInUser(ctx context.Context, query *models.GetSigned
|
|||||||
user.OrgName = "Org missing"
|
user.OrgName = "Org missing"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.ExternalAuthModule != "oauth_grafana_com" {
|
||||||
|
user.ExternalAuthId = ""
|
||||||
|
}
|
||||||
|
|
||||||
getTeamsByUserQuery := &models.GetTeamsByUserQuery{OrgId: user.OrgId, UserId: user.UserId}
|
getTeamsByUserQuery := &models.GetTeamsByUserQuery{OrgId: user.OrgId, UserId: user.UserId}
|
||||||
err = ss.GetTeamsByUser(ctx, getTeamsByUserQuery)
|
err = ss.GetTeamsByUser(ctx, getTeamsByUserQuery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user