diff --git a/controllers/auth.go b/controllers/auth.go index 45150963..8127993f 100644 --- a/controllers/auth.go +++ b/controllers/auth.go @@ -399,10 +399,14 @@ func (c *ApiController) Login() { c.ResponseError(fmt.Sprintf(c.T("auth:The application: %s does not exist"), authForm.Application)) return } - if !application.IsPasswordEnabled() { + if authForm.SigninMethod == "Password" && !application.IsPasswordEnabled() { c.ResponseError(c.T("auth:The login method: login with password is not enabled for the application")) return } + if authForm.SigninMethod == "LDAP" && !application.IsLdapEnabled() { + c.ResponseError(c.T("auth:The login method: login with LDAP is not enabled for the application")) + return + } var enableCaptcha bool if enableCaptcha, err = object.CheckToEnableCaptcha(application, authForm.Organization, authForm.Username); err != nil { c.ResponseError(err.Error()) @@ -432,7 +436,14 @@ func (c *ApiController) Login() { } password := authForm.Password - user, err = object.CheckUserPassword(authForm.Organization, authForm.Username, password, c.GetAcceptLanguage(), enableCaptcha) + isSigninViaLdap := authForm.SigninMethod == "LDAP" + var isPasswordWithLdapEnabled bool + if authForm.SigninMethod == "Password" { + isPasswordWithLdapEnabled = application.IsPasswordWithLdapEnabled() + } else { + isPasswordWithLdapEnabled = false + } + user, err = object.CheckUserPassword(authForm.Organization, authForm.Username, password, c.GetAcceptLanguage(), enableCaptcha, isSigninViaLdap, isPasswordWithLdapEnabled) } if err != nil { diff --git a/form/auth.go b/form/auth.go index 02b209fa..464a3135 100644 --- a/form/auth.go +++ b/form/auth.go @@ -15,7 +15,8 @@ package form type AuthForm struct { - Type string `json:"type"` + Type string `json:"type"` + SigninMethod string `json:"signinMethod"` Organization string `json:"organization"` Username string `json:"username"` diff --git a/i18n/locales/ar/data.json b/i18n/locales/ar/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/ar/data.json +++ b/i18n/locales/ar/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/de/data.json b/i18n/locales/de/data.json index a07d102d..d6422063 100644 --- a/i18n/locales/de/data.json +++ b/i18n/locales/de/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "Das Konto für den Anbieter %s und Benutzernamen %s (%s) existiert nicht und es ist nicht erlaubt, ein neues Konto anzumelden. Bitte wenden Sie sich an Ihren IT-Support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "Das Konto für den Anbieter %s und Benutzernamen %s (%s) ist bereits mit einem anderen Konto verknüpft: %s (%s)", "The application: %s does not exist": "Die Anwendung: %s existiert nicht", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "Die Anmeldeart \"Anmeldung mit Passwort\" ist für die Anwendung nicht aktiviert", diff --git a/i18n/locales/en/data.json b/i18n/locales/en/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/en/data.json +++ b/i18n/locales/en/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/es/data.json b/i18n/locales/es/data.json index 5510005d..bc0781d3 100644 --- a/i18n/locales/es/data.json +++ b/i18n/locales/es/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "La cuenta para el proveedor: %s y el nombre de usuario: %s (%s) no existe y no se permite registrarse como una nueva cuenta, por favor contacte a su soporte de TI", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "La cuenta para proveedor: %s y nombre de usuario: %s (%s) ya está vinculada a otra cuenta: %s (%s)", "The application: %s does not exist": "La aplicación: %s no existe", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "El método de inicio de sesión: inicio de sesión con contraseña no está habilitado para la aplicación", diff --git a/i18n/locales/fa/data.json b/i18n/locales/fa/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/fa/data.json +++ b/i18n/locales/fa/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/fi/data.json b/i18n/locales/fi/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/fi/data.json +++ b/i18n/locales/fi/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/fr/data.json b/i18n/locales/fr/data.json index 36a83edc..b5e80391 100644 --- a/i18n/locales/fr/data.json +++ b/i18n/locales/fr/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "Le compte pour le fournisseur : %s et le nom d'utilisateur : %s (%s) n'existe pas et n'est pas autorisé à s'inscrire comme nouveau compte, veuillez contacter votre support informatique", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "Le compte du fournisseur : %s et le nom d'utilisateur : %s (%s) sont déjà liés à un autre compte : %s (%s)", "The application: %s does not exist": "L'application : %s n'existe pas", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "La méthode de connexion : connexion avec mot de passe n'est pas activée pour l'application", diff --git a/i18n/locales/he/data.json b/i18n/locales/he/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/he/data.json +++ b/i18n/locales/he/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/id/data.json b/i18n/locales/id/data.json index 32c91a1d..5804eabc 100644 --- a/i18n/locales/id/data.json +++ b/i18n/locales/id/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "Akun untuk penyedia: %s dan nama pengguna: %s (%s) tidak ada dan tidak diizinkan untuk mendaftar sebagai akun baru, silakan hubungi dukungan IT Anda", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "Akun untuk provider: %s dan username: %s (%s) sudah terhubung dengan akun lain: %s (%s)", "The application: %s does not exist": "Aplikasi: %s tidak ada", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "Metode login: login dengan kata sandi tidak diaktifkan untuk aplikasi tersebut", diff --git a/i18n/locales/it/data.json b/i18n/locales/it/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/it/data.json +++ b/i18n/locales/it/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/ja/data.json b/i18n/locales/ja/data.json index fab0884f..56e298d8 100644 --- a/i18n/locales/ja/data.json +++ b/i18n/locales/ja/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "プロバイダー名:%sとユーザー名:%s(%s)のアカウントは存在しません。新しいアカウントとしてサインアップすることはできません。 ITサポートに連絡してください", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "プロバイダのアカウント:%s とユーザー名:%s (%s) は既に別のアカウント:%s (%s) にリンクされています", "The application: %s does not exist": "アプリケーション: %sは存在しません", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "ログイン方法:パスワードでのログインはアプリケーションで有効になっていません", diff --git a/i18n/locales/kk/data.json b/i18n/locales/kk/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/kk/data.json +++ b/i18n/locales/kk/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/ko/data.json b/i18n/locales/ko/data.json index 22597506..bd3cb5c3 100644 --- a/i18n/locales/ko/data.json +++ b/i18n/locales/ko/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "공급자 계정 %s과 사용자 이름 %s (%s)는 존재하지 않으며 새 계정으로 등록할 수 없습니다. IT 지원팀에 문의하십시오", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "공급자 계정 %s과 사용자 이름 %s(%s)는 이미 다른 계정 %s(%s)에 연결되어 있습니다", "The application: %s does not exist": "해당 애플리케이션(%s)이 존재하지 않습니다", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "어플리케이션에서는 암호를 사용한 로그인 방법이 활성화되어 있지 않습니다", diff --git a/i18n/locales/ms/data.json b/i18n/locales/ms/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/ms/data.json +++ b/i18n/locales/ms/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/nl/data.json b/i18n/locales/nl/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/nl/data.json +++ b/i18n/locales/nl/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/pl/data.json b/i18n/locales/pl/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/pl/data.json +++ b/i18n/locales/pl/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/pt/data.json b/i18n/locales/pt/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/pt/data.json +++ b/i18n/locales/pt/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/ru/data.json b/i18n/locales/ru/data.json index 0ea39d34..02bd58e8 100644 --- a/i18n/locales/ru/data.json +++ b/i18n/locales/ru/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "Аккаунт для провайдера: %s и имя пользователя: %s (%s) не существует и не может быть зарегистрирован как новый аккаунт. Пожалуйста, обратитесь в службу поддержки IT", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "Аккаунт поставщика: %s и имя пользователя: %s (%s) уже связаны с другим аккаунтом: %s (%s)", "The application: %s does not exist": "Приложение: %s не существует", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "Метод входа: вход с паролем не включен для приложения", diff --git a/i18n/locales/sv/data.json b/i18n/locales/sv/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/sv/data.json +++ b/i18n/locales/sv/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/tr/data.json b/i18n/locales/tr/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/tr/data.json +++ b/i18n/locales/tr/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/uk/data.json b/i18n/locales/uk/data.json index 2987a3f8..e5f85f3e 100644 --- a/i18n/locales/uk/data.json +++ b/i18n/locales/uk/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)", "The application: %s does not exist": "The application: %s does not exist", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", diff --git a/i18n/locales/vi/data.json b/i18n/locales/vi/data.json index 9f276de0..16bb4597 100644 --- a/i18n/locales/vi/data.json +++ b/i18n/locales/vi/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "Tài khoản cho nhà cung cấp: %s và tên người dùng: %s (%s) không tồn tại và không được phép đăng ký như một tài khoản mới, vui lòng liên hệ với bộ phận hỗ trợ công nghệ thông tin của bạn", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "Tài khoản cho nhà cung cấp: %s và tên người dùng: %s (%s) đã được liên kết với tài khoản khác: %s (%s)", "The application: %s does not exist": "Ứng dụng: %s không tồn tại", + "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", "The login method: login with password is not enabled for the application": "Phương thức đăng nhập: đăng nhập bằng mật khẩu không được kích hoạt cho ứng dụng", diff --git a/i18n/locales/zh/data.json b/i18n/locales/zh/data.json index a52e42b9..76e2c924 100644 --- a/i18n/locales/zh/data.json +++ b/i18n/locales/zh/data.json @@ -15,6 +15,7 @@ "The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support": "提供商账户: %s 与用户名: %s (%s) 不存在且 不允许注册新账户, 请联系IT支持", "The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s)": "提供商账户: %s与用户名: %s (%s)已经与其他账户绑定: %s (%s)", "The application: %s does not exist": "应用%s不存在", + "The login method: login with LDAP is not enabled for the application": "该应用禁止采用LDAP登录方式", "The login method: login with SMS is not enabled for the application": "该应用禁止采用短信登录方式", "The login method: login with email is not enabled for the application": "该应用禁止采用邮箱登录方式", "The login method: login with password is not enabled for the application": "该应用禁止采用密码登录方式", diff --git a/init_data.json.template b/init_data.json.template index 872a5abe..41c09d62 100644 --- a/init_data.json.template +++ b/init_data.json.template @@ -49,7 +49,7 @@ { "name": "Password", "displayName": "Password", - "rule": "None", + "rule": "All", }, { "name": "Verification code", @@ -61,6 +61,11 @@ "displayName": "WebAuthn", "rule": "None", }, + { + "name": "LDAP", + "displayName": "LDAP", + "rule": "None", + }, ], "signupItems": [ { diff --git a/object/application.go b/object/application.go index b68adb07..e64bafbd 100644 --- a/object/application.go +++ b/object/application.go @@ -201,7 +201,7 @@ func extendApplicationWithOrg(application *Application) (err error) { func extendApplicationWithSigninMethods(application *Application) (err error) { if len(application.SigninMethods) == 0 { if application.EnablePassword { - signinMethod := &SigninMethod{Name: "Password", DisplayName: "Password", Rule: "None"} + signinMethod := &SigninMethod{Name: "Password", DisplayName: "Password", Rule: "All"} application.SigninMethods = append(application.SigninMethods, signinMethod) } if application.EnableCodeSignin { @@ -212,10 +212,12 @@ func extendApplicationWithSigninMethods(application *Application) (err error) { signinMethod := &SigninMethod{Name: "WebAuthn", DisplayName: "WebAuthn", Rule: "None"} application.SigninMethods = append(application.SigninMethods, signinMethod) } + signinMethod := &SigninMethod{Name: "LDAP", DisplayName: "LDAP", Rule: "None"} + application.SigninMethods = append(application.SigninMethods, signinMethod) } if len(application.SigninMethods) == 0 { - signinMethod := &SigninMethod{Name: "Password", DisplayName: "Password", Rule: "None"} + signinMethod := &SigninMethod{Name: "Password", DisplayName: "Password", Rule: "All"} application.SigninMethods = append(application.SigninMethods, signinMethod) } @@ -544,6 +546,19 @@ func (application *Application) IsPasswordEnabled() bool { } } +func (application *Application) IsPasswordWithLdapEnabled() bool { + if len(application.SigninMethods) == 0 { + return application.EnablePassword + } else { + for _, signinMethod := range application.SigninMethods { + if signinMethod.Name == "Password" && signinMethod.Rule == "All" { + return true + } + } + return false + } +} + func (application *Application) IsCodeSigninViaEmailEnabled() bool { if len(application.SigninMethods) == 0 { return application.EnableCodeSignin @@ -570,6 +585,17 @@ func (application *Application) IsCodeSigninViaSmsEnabled() bool { } } +func (application *Application) IsLdapEnabled() bool { + if len(application.SigninMethods) > 0 { + for _, signinMethod := range application.SigninMethods { + if signinMethod.Name == "LDAP" { + return true + } + } + } + return false +} + func IsOriginAllowed(origin string) (bool, error) { applications, err := GetApplications("") if err != nil { diff --git a/object/check.go b/object/check.go index fdbb7b71..2166f592 100644 --- a/object/check.go +++ b/object/check.go @@ -278,8 +278,12 @@ func checkLdapUserPassword(user *User, password string, lang string) error { func CheckUserPassword(organization string, username string, password string, lang string, options ...bool) (*User, error) { enableCaptcha := false + isSigninViaLdap := false + isPasswordWithLdapEnabled := false if len(options) > 0 { enableCaptcha = options[0] + isSigninViaLdap = options[1] + isPasswordWithLdapEnabled = options[2] } user, err := GetUserByFields(organization, username) if err != nil { @@ -294,7 +298,16 @@ func CheckUserPassword(organization string, username string, password string, la return nil, fmt.Errorf(i18n.Translate(lang, "check:The user is forbidden to sign in, please contact the administrator")) } + if isSigninViaLdap { + if user.Ldap == "" { + return nil, fmt.Errorf(i18n.Translate(lang, "check:The user: %s doesn't exist in LDAP server"), username) + } + } + if user.Ldap != "" { + if !isSigninViaLdap && !isPasswordWithLdapEnabled { + return nil, fmt.Errorf(i18n.Translate(lang, "check:password or code is incorrect")) + } // only for LDAP users err = checkLdapUserPassword(user, password, lang) if err != nil { diff --git a/object/init.go b/object/init.go index edd9da25..2da23fa5 100644 --- a/object/init.go +++ b/object/init.go @@ -184,6 +184,7 @@ func initBuiltInApplication() { {Name: "Password", DisplayName: "Password", Rule: "None"}, {Name: "Verification code", DisplayName: "Verification code", Rule: "All"}, {Name: "WebAuthn", DisplayName: "WebAuthn", Rule: "None"}, + {Name: "LDAP", DisplayName: "LDAP", Rule: "None"}, }, SignupItems: []*SignupItem{ {Name: "ID", Visible: false, Required: true, Prompted: false, Rule: "Random"}, diff --git a/web/src/ApplicationEditPage.js b/web/src/ApplicationEditPage.js index 156934d1..ca2f644e 100644 --- a/web/src/ApplicationEditPage.js +++ b/web/src/ApplicationEditPage.js @@ -1034,7 +1034,7 @@ class ApplicationEditPage extends React.Component { submitApplicationEdit(exitAfterSave) { const application = Setting.deepCopy(this.state.application); application.providers = application.providers?.filter(provider => this.state.providers.map(provider => provider.name).includes(provider.name)); - application.signinMethods = application.signinMethods?.filter(signinMethod => ["Password", "Verification code", "WebAuthn"].includes(signinMethod.name)); + application.signinMethods = application.signinMethods?.filter(signinMethod => ["Password", "Verification code", "WebAuthn", "LDAP"].includes(signinMethod.name)); ApplicationBackend.updateApplication("admin", this.state.applicationName, application) .then((res) => { diff --git a/web/src/ApplicationListPage.js b/web/src/ApplicationListPage.js index 9a0438c5..6f3ebeb4 100644 --- a/web/src/ApplicationListPage.js +++ b/web/src/ApplicationListPage.js @@ -47,9 +47,10 @@ class ApplicationListPage extends BaseListPage { {name: "provider_captcha_default", canSignUp: false, canSignIn: false, canUnlink: false, prompted: false, signupGroup: "", rule: ""}, ], SigninMethods: [ - {name: "Password", displayName: "Password", rule: "None"}, + {name: "Password", displayName: "Password", rule: "All"}, {name: "Verification code", displayName: "Verification code", rule: "All"}, {name: "WebAuthn", displayName: "WebAuthn", rule: "None"}, + {name: "LDAP", displayName: "LDAP", rule: "None"}, ], signupItems: [ {name: "ID", visible: false, required: true, rule: "Random"}, diff --git a/web/src/Setting.js b/web/src/Setting.js index 5dd960ef..0666d549 100644 --- a/web/src/Setting.js +++ b/web/src/Setting.js @@ -1155,6 +1155,14 @@ export function isWebAuthnEnabled(application) { } } +export function isLdapEnabled(application) { + if (application) { + return application.signinMethods.filter(item => item.name === "LDAP").length > 0; + } else { + return false; + } +} + export function getLoginLink(application) { let url; if (application === null) { diff --git a/web/src/auth/LoginPage.js b/web/src/auth/LoginPage.js index ea660e83..3f077b7a 100644 --- a/web/src/auth/LoginPage.js +++ b/web/src/auth/LoginPage.js @@ -213,6 +213,7 @@ class LoginPage extends React.Component { break; } case "WebAuthn": return "webAuthn"; + case "LDAP": return "ldap"; } } @@ -224,6 +225,7 @@ class LoginPage extends React.Component { case "verificationCode": return i18next.t("login:Email or phone"); case "verificationCodeEmail": return i18next.t("login:Email"); case "verificationCodePhone": return i18next.t("login:Phone"); + case "ldap": return i18next.t("login:LDAP username, Email or phone"); default: return i18next.t("login:username, Email or phone"); } } @@ -253,6 +255,15 @@ class LoginPage extends React.Component { values["organization"] = this.getApplicationObj().organization; } + if (this.state.loginMethod === "password") { + values["signinMethod"] = "Password"; + } else if (this.state.loginMethod?.includes("verificationCode")) { + values["signinMethod"] = "Verification code"; + } else if (this.state.loginMethod === "webAuthn") { + values["signinMethod"] = "WebAuthn"; + } else if (this.state.loginMethod === "ldap") { + values["signinMethod"] = "LDAP"; + } const oAuthParams = Util.getOAuthGetParameters(); values["type"] = oAuthParams?.responseType ?? this.state.type; @@ -329,7 +340,7 @@ class LoginPage extends React.Component { this.signInWithWebAuthn(username, values); return; } - if (this.state.loginMethod === "password") { + if (this.state.loginMethod === "password" || this.state.loginMethod === "ldap") { if (this.state.enableCaptchaModal === CaptchaRule.Always) { this.setState({ openCaptchaModal: true, @@ -507,7 +518,7 @@ class LoginPage extends React.Component { ); } - const showForm = Setting.isPasswordEnabled(application) || Setting.isCodeSigninEnabled(application) || Setting.isWebAuthnEnabled(application); + const showForm = Setting.isPasswordEnabled(application) || Setting.isCodeSigninEnabled(application) || Setting.isWebAuthnEnabled(application) || Setting.isLdapEnabled(application); if (showForm) { let loginWidth = 320; if (Setting.getLanguage() === "fr") { @@ -570,6 +581,7 @@ class LoginPage extends React.Component { switch (this.state.loginMethod) { case "verificationCodeEmail": return i18next.t("login:Please input your Email!"); case "verificationCodePhone": return i18next.t("login:Please input your Phone!"); + case "ldap": return i18next.t("login:Please input your LDAP username!"); default: return i18next.t("login:Please input your Email or Phone!"); } }, @@ -870,7 +882,7 @@ class LoginPage extends React.Component { renderPasswordOrCodeInput() { const application = this.getApplicationObj(); - if (this.state.loginMethod === "password") { + if (this.state.loginMethod === "password" || this.state.loginMethod === "ldap") { return (