Auth: Remove Email Lookup from oauth integrations 9.4 (#896)
backport https://github.com/grafana/grafana-private-mirror/pull/894 to 9.4.x
This commit is contained in:
@@ -314,16 +314,17 @@ func (hs *HTTPServer) SyncUser(
|
|||||||
connect social.SocialConnector,
|
connect social.SocialConnector,
|
||||||
) (*user.User, error) {
|
) (*user.User, error) {
|
||||||
oauthLogger.Debug("Syncing Grafana user with corresponding OAuth profile")
|
oauthLogger.Debug("Syncing Grafana user with corresponding OAuth profile")
|
||||||
|
lookupParams := loginservice.UserLookupParams{}
|
||||||
|
if hs.Cfg.OAuthAllowInsecureEmailLookup {
|
||||||
|
lookupParams.Email = &extUser.Email
|
||||||
|
}
|
||||||
|
|
||||||
// add/update user in Grafana
|
// add/update user in Grafana
|
||||||
cmd := &loginservice.UpsertUserCommand{
|
cmd := &loginservice.UpsertUserCommand{
|
||||||
ReqContext: ctx,
|
ReqContext: ctx,
|
||||||
ExternalUser: extUser,
|
ExternalUser: extUser,
|
||||||
SignupAllowed: connect.IsSignupAllowed(),
|
SignupAllowed: connect.IsSignupAllowed(),
|
||||||
UserLookupParams: loginservice.UserLookupParams{
|
UserLookupParams: lookupParams,
|
||||||
Email: &extUser.Email,
|
|
||||||
UserID: nil,
|
|
||||||
Login: nil,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := hs.Login.UpsertUser(ctx.Req.Context(), cmd); err != nil {
|
if err := hs.Login.UpsertUser(ctx.Req.Context(), cmd); err != nil {
|
||||||
|
|||||||
@@ -326,7 +326,8 @@ type Cfg struct {
|
|||||||
AuthProxySyncTTL int
|
AuthProxySyncTTL int
|
||||||
|
|
||||||
// OAuth
|
// OAuth
|
||||||
OAuthCookieMaxAge int
|
OAuthCookieMaxAge int
|
||||||
|
OAuthAllowInsecureEmailLookup bool
|
||||||
|
|
||||||
// JWT Auth
|
// JWT Auth
|
||||||
JWTAuthEnabled bool
|
JWTAuthEnabled bool
|
||||||
@@ -1457,6 +1458,8 @@ func readAuthSettings(iniFile *ini.File, cfg *Cfg) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg.OAuthAllowInsecureEmailLookup = auth.Key("oauth_allow_insecure_email_lookup").MustBool(false)
|
||||||
|
|
||||||
const defaultMaxLifetime = "30d"
|
const defaultMaxLifetime = "30d"
|
||||||
maxLifetimeDurationVal := valueAsString(auth, "login_maximum_lifetime_duration", defaultMaxLifetime)
|
maxLifetimeDurationVal := valueAsString(auth, "login_maximum_lifetime_duration", defaultMaxLifetime)
|
||||||
cfg.LoginMaxLifetime, err = gtime.ParseDuration(maxLifetimeDurationVal)
|
cfg.LoginMaxLifetime, err = gtime.ParseDuration(maxLifetimeDurationVal)
|
||||||
|
|||||||
Reference in New Issue
Block a user