Auth: Remove Email Lookup from oauth integrations 9.2 (#898)

backport https://github.com/grafana/grafana-private-mirror/pull/894 to 9.3.x
This commit is contained in:
Ieva
2023-06-07 08:22:50 +02:00
committed by Horst Gutmann
parent 7078e75abf
commit bae86dbeb0
2 changed files with 13 additions and 9 deletions
+9 -8
View File
@@ -302,16 +302,17 @@ func (hs *HTTPServer) SyncUser(
connect social.SocialConnector,
) (*user.User, error) {
oauthLogger.Debug("Syncing Grafana user with corresponding OAuth profile")
lookupParams := models.UserLookupParams{}
if hs.Cfg.OAuthAllowInsecureEmailLookup {
lookupParams.Email = &extUser.Email
}
// add/update user in Grafana
cmd := &models.UpsertUserCommand{
ReqContext: ctx,
ExternalUser: extUser,
SignupAllowed: connect.IsSignupAllowed(),
UserLookupParams: models.UserLookupParams{
Email: &extUser.Email,
UserID: nil,
Login: nil,
},
ReqContext: ctx,
ExternalUser: extUser,
SignupAllowed: connect.IsSignupAllowed(),
UserLookupParams: lookupParams,
}
if err := hs.Login.UpsertUser(ctx.Req.Context(), cmd); err != nil {
+4 -1
View File
@@ -318,7 +318,8 @@ type Cfg struct {
AuthProxySyncTTL int
// OAuth
OAuthCookieMaxAge int
OAuthCookieMaxAge int
OAuthAllowInsecureEmailLookup bool
// JWT Auth
JWTAuthEnabled bool
@@ -1305,6 +1306,8 @@ func readAuthSettings(iniFile *ini.File, cfg *Cfg) (err error) {
return err
}
cfg.OAuthAllowInsecureEmailLookup = auth.Key("oauth_allow_insecure_email_lookup").MustBool(false)
const defaultMaxLifetime = "30d"
maxLifetimeDurationVal := valueAsString(auth, "login_maximum_lifetime_duration", defaultMaxLifetime)
cfg.LoginMaxLifetime, err = gtime.ParseDuration(maxLifetimeDurationVal)