Add Config to disable Auth Transfers. (#7843)
* Add Config to disable Auth Transfers. * Set config ExperimentalEnableAuthenticationTransfer behind an E20 license restriction
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
785a410936
Коммит
27ba68a789
@@ -194,6 +194,7 @@ func (a *App) trackConfig() {
|
||||
"enable_user_access_tokens": *cfg.ServiceSettings.EnableUserAccessTokens,
|
||||
"enable_custom_emoji": *cfg.ServiceSettings.EnableCustomEmoji,
|
||||
"enable_emoji_picker": *cfg.ServiceSettings.EnableEmojiPicker,
|
||||
"experimental_enable_authentication_transfer": *cfg.ServiceSettings.ExperimentalEnableAuthenticationTransfer,
|
||||
"restrict_custom_emoji_creation": *cfg.ServiceSettings.RestrictCustomEmojiCreation,
|
||||
"enable_testing": cfg.ServiceSettings.EnableTesting,
|
||||
"enable_developer": *cfg.ServiceSettings.EnableDeveloper,
|
||||
|
||||
@@ -39,6 +39,10 @@ func (a *App) TestLdap() *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) SwitchEmailToLdap(email, password, code, ldapId, ldapPassword string) (string, *model.AppError) {
|
||||
if utils.IsLicensed() && !*a.Config().ServiceSettings.ExperimentalEnableAuthenticationTransfer {
|
||||
return "", model.NewAppError("emailToLdap", "api.user.email_to_ldap.not_available.app_error", nil, "", http.StatusForbidden)
|
||||
}
|
||||
|
||||
user, err := a.GetUserByEmail(email)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -71,6 +75,10 @@ func (a *App) SwitchEmailToLdap(email, password, code, ldapId, ldapPassword stri
|
||||
}
|
||||
|
||||
func (a *App) SwitchLdapToEmail(ldapPassword, code, email, newPassword string) (string, *model.AppError) {
|
||||
if utils.IsLicensed() && !*a.Config().ServiceSettings.ExperimentalEnableAuthenticationTransfer {
|
||||
return "", model.NewAppError("ldapToEmail", "api.user.ldap_to_email.not_available.app_error", nil, "", http.StatusForbidden)
|
||||
}
|
||||
|
||||
user, err := a.GetUserByEmail(email)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -717,6 +717,10 @@ func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service
|
||||
}
|
||||
|
||||
func (a *App) SwitchEmailToOAuth(w http.ResponseWriter, r *http.Request, email, password, code, service string) (string, *model.AppError) {
|
||||
if utils.IsLicensed() && !*a.Config().ServiceSettings.ExperimentalEnableAuthenticationTransfer {
|
||||
return "", model.NewAppError("emailToOAuth", "api.user.email_to_oauth.not_available.app_error", nil, "", http.StatusForbidden)
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
var err *model.AppError
|
||||
if user, err = a.GetUserByEmail(email); err != nil {
|
||||
@@ -743,6 +747,10 @@ func (a *App) SwitchEmailToOAuth(w http.ResponseWriter, r *http.Request, email,
|
||||
}
|
||||
|
||||
func (a *App) SwitchOAuthToEmail(email, password, requesterId string) (string, *model.AppError) {
|
||||
if utils.IsLicensed() && !*a.Config().ServiceSettings.ExperimentalEnableAuthenticationTransfer {
|
||||
return "", model.NewAppError("oauthToEmail", "api.user.oauth_to_email.not_available.app_error", nil, "", http.StatusForbidden)
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
var err *model.AppError
|
||||
if user, err = a.GetUserByEmail(email); err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user