CLOUDSTACK-9928: Allow native CloudStack users to change password in UI

This allows native CloudStack users to change password in UI when LDAP
is enabled. Overall changes:
- A new usersource returned in the listUsers response
- Removed ldap check in the UI, replaced with check based on user source
- DB changes to include user.source in user_view
- Changed UI error message for non-native users trying to change password

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2017-05-25 16:18:15 +05:30 committed by Rohit Yadav
parent 3a70c5cd16
commit 322e18a7b6
25 changed files with 114 additions and 35 deletions

View File

@ -93,6 +93,7 @@ env:
smoke/misc/test_vm_sync"
- TESTS="component/find_hosts_for_migration
component/test_accounts
component/test_acl_isolatednetwork_delete
component/test_acl_listsnapshot
component/test_acl_listvm
@ -146,7 +147,6 @@ env:
# - TESTS="component/test_project_resources"
# - TESTS="component/test_cpu_domain_limits"
# - TESTS="component/test_acl_isolatednetwork"
# - TESTS="component/test_accounts"
# - TESTS="component/test_organization_states"
before_install: travis_wait 30 ./tools/travis/before_install.sh

View File

@ -22,8 +22,9 @@ import org.apache.cloudstack.api.InternalIdentity;
public interface User extends OwnedBy, InternalIdentity {
// UNKNOWN and NATIVE can be used interchangeably
public enum Source {
LDAP, SAML2, SAML2DISABLED, UNKNOWN
LDAP, SAML2, SAML2DISABLED, UNKNOWN, NATIVE
}
public static final long UID_SYSTEM = 1;

View File

@ -66,6 +66,10 @@ public class UserResponse extends BaseResponse {
@Param(description = "the account type of the user")
private Short accountType;
@SerializedName("usersource")
@Param(description = "the source type of the user in lowercase, such as native, ldap, saml2")
private String userSource;
@SerializedName(ApiConstants.ROLE_ID)
@Param(description = "the ID of the role")
private String roleId;
@ -260,4 +264,15 @@ public class UserResponse extends BaseResponse {
public void setIsDefault(Boolean isDefault) {
this.isDefault = isDefault;
}
public String getUserSource() {
return userSource;
}
public void setUserSource(User.Source userSource) {
this.userSource = userSource.toString().toLowerCase();
if (this.userSource.equals(User.Source.UNKNOWN.toString().toLowerCase())) {
this.userSource = User.Source.NATIVE.toString().toLowerCase();
}
}
}

View File

@ -58,6 +58,7 @@ public class UserAccountJoinDaoImpl extends GenericDaoBase<UserAccountJoinVO, Lo
userResponse.setAccountId(usr.getAccountUuid());
userResponse.setAccountName(usr.getAccountName());
userResponse.setAccountType(usr.getAccountType());
userResponse.setUserSource(usr.getSource());
userResponse.setCreated(usr.getCreated());
userResponse.setDomainId(usr.getDomainUuid());
userResponse.setDomainName(usr.getDomainName());

View File

@ -16,19 +16,20 @@
// under the License.
package com.cloud.api.query.vo;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.user.User;
import com.cloud.user.UserAccount;
import com.cloud.utils.db.Encrypt;
import com.cloud.utils.db.GenericDao;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
@Entity
@Table(name = "user_view")
@ -123,6 +124,10 @@ public class UserAccountJoinVO extends BaseViewVO implements InternalIdentity, I
@Column(name = "default")
boolean isDefault;
@Column(name = "source")
@Enumerated(value = EnumType.STRING)
private User.Source source;
public UserAccountJoinVO() {
}
@ -258,4 +263,8 @@ public class UserAccountJoinVO extends BaseViewVO implements InternalIdentity, I
public String getProjectName() {
return null;
}
public User.Source getSource() {
return source;
}
}

View File

@ -22,3 +22,48 @@
DELETE FROM `cloud`.`configuration` WHERE name='consoleproxy.loadscan.interval';
DELETE FROM `cloud`.`host_details` where name = 'vmName' and value in (select name from `cloud`.`vm_instance` where state = 'Expunging' and hypervisor_type ='BareMetal');
DROP VIEW IF EXISTS `cloud`.`user_view`;
CREATE VIEW `cloud`.`user_view` AS
select
user.id,
user.uuid,
user.username,
user.password,
user.firstname,
user.lastname,
user.email,
user.state,
user.api_key,
user.secret_key,
user.created,
user.removed,
user.timezone,
user.registration_token,
user.is_registered,
user.incorrect_login_attempts,
user.source,
user.default,
account.id account_id,
account.uuid account_uuid,
account.account_name account_name,
account.type account_type,
account.role_id account_role_id,
domain.id domain_id,
domain.uuid domain_uuid,
domain.name domain_name,
domain.path domain_path,
async_job.id job_id,
async_job.uuid job_uuid,
async_job.job_status job_status,
async_job.account_id job_account_id
from
`cloud`.`user`
inner join
`cloud`.`account` ON user.account_id = account.id
inner join
`cloud`.`domain` ON account.domain_id = domain.id
left join
`cloud`.`async_job` ON async_job.instance_id = user.id
and async_job.instance_type = 'User'
and async_job.job_status = 0;

View File

@ -96,7 +96,7 @@ class Services:
"template": {
"displaytext": "Public Template",
"name": "Public template",
"ostype": 'CentOS 5.3 (64-bit)',
"ostype": 'CentOS 5.6 (64-bit)',
"url": "",
"hypervisor": '',
"format": '',
@ -110,8 +110,7 @@ class Services:
"privateport": 22,
"protocol": 'TCP',
},
"ostype": 'CentOS 5.3 (64-bit)',
# Cent OS 5.3 (64 bit)
"ostype": 'CentOS 5.6 (64-bit)',
"sleep": 60,
"timeout": 10,
}
@ -249,6 +248,11 @@ class TestAccounts(cloudstackTestCase):
user_response.state,
"Check state of created user"
)
self.assertEqual(
"native",
user_response.usersource,
"Check user source of created user"
)
return

View File

@ -232,6 +232,9 @@ class CodeGenerator(object):
for cmdName in self.cmdsName:
body += self.space
if cmdName in ["login", "logout"]:
body += 'def %s(self, command, method="POST"):\n' % cmdName
else:
body += 'def %s(self, command, method="GET"):\n' % cmdName
body += self.space + self.space
body += 'response = %sResponse()\n' % cmdName

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "تغير خصائص العنصر",
"confirm.enable.s3": "فضلا قم بتعبئة البيانات القادمة لتمكين التخزين S3 للذاكرة الثانوية.",
"confirm.enable.swift": "Please fill in the following information to enable support for Swift",
"error.could.not.change.your.password.because.ldap.is.enabled": "Error could not change your password because LDAP is enabled.",
"error.could.not.change.your.password.because.non.native.user": "Error could not change your password because LDAP is enabled.",
"error.could.not.enable.zone": "Could not enable zone",
"error.installWizard.message": "Something went wrong; you may go back and correct any errors",
"error.invalid.username.password": "Invalid username or password",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "Changed item properties",
"confirm.enable.s3": "Please fill in the following information to enable support for S3-backed Secondary Storage",
"confirm.enable.swift": "Si us plau ompliu la següent informació per habilitar el suport per a Swift",
"error.could.not.change.your.password.because.ldap.is.enabled": "Error could not change your password because LDAP is enabled.",
"error.could.not.change.your.password.because.non.native.user": "Error could not change your password because LDAP is enabled.",
"error.could.not.enable.zone": "Could not enable zone",
"error.installWizard.message": "Quelcom ha fallat, vostè pot tornar enrere i corregir els errors detalls suggerime",
"error.invalid.username.password": "Invalid username or password",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "Geänderte Eintragseigenschaften",
"confirm.enable.s3": "Bitte fügen Sie die folgenden Informationen hinzu, um die Unterstützung für \"S3-backed Secondary Storage\" hinzuzufügen",
"confirm.enable.swift": "Bitte fügen Sie die folgenden Informationen hinzu, um die Unterstützung für Swift zu ermöglichen.",
"error.could.not.change.your.password.because.ldap.is.enabled": "Fehler! Ihr Passwort konnte nicht geändert werden, weil LDAP konfiguriert wurde.",
"error.could.not.change.your.password.because.non.native.user": "Fehler! Ihr Passwort konnte nicht geändert werden, weil LDAP konfiguriert wurde.",
"error.could.not.enable.zone": "Zone konnte nicht aktiviert werden",
"error.installWizard.message": "Etwas ging schief; Sie können zurückgehen um mögliche Fehler zu beheben",
"error.invalid.username.password": "Ungültiger Benutzername oder ungültiges Passwort",

View File

@ -19,7 +19,7 @@ var dictionary = {"ICMP.code":"ICMP Code",
"changed.item.properties":"Changed item properties",
"confirm.enable.s3":"Please fill in the following information to enable support for S3-backed Secondary Storage",
"confirm.enable.swift":"Please fill in the following information to enable support for Swift",
"error.could.not.change.your.password.because.ldap.is.enabled":"Error could not change your password because LDAP is enabled.",
"error.could.not.change.your.password.because.non.native.user":"Error could not change your password because user is not a native CloudStack user.",
"error.could.not.enable.zone":"Could not enable zone",
"error.installWizard.message":"Something went wrong; you may go back and correct any errors",
"error.invalid.username.password":"Invalid username or password",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "Cambiadas las propiedades del elemento",
"confirm.enable.s3": "Por favor, complete la siguiente información para habilitar el soporte del Almacenamiento Secundario sobre S3",
"confirm.enable.swift": "Por favor, complete la siguiente información para habilitar el soporte para Swift",
"error.could.not.change.your.password.because.ldap.is.enabled": "Error, no se puede cambiar la contraseña porque LDAP esta activado",
"error.could.not.change.your.password.because.non.native.user": "Error, no se puede cambiar la contraseña porque LDAP esta activado",
"error.could.not.enable.zone": "No se pudo habilitar la zona",
"error.installWizard.message": "Algo salio mal, debes ir para atrás y corregir los errores.",
"error.invalid.username.password": "Usuario o contraseña invalido",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "Propriétés de l'élément modifiées",
"confirm.enable.s3": "Remplir les informations suivantes pour activer le support de stockage secondaire S3",
"confirm.enable.swift": "Remplir les informations suivantes pour activer Swift",
"error.could.not.change.your.password.because.ldap.is.enabled": "Erreur: impossible de changer votre mot de passe car le mode LDAP est activé.",
"error.could.not.change.your.password.because.non.native.user": "Erreur: impossible de changer votre mot de passe car le mode LDAP est activé.",
"error.could.not.enable.zone": "Impossible d'activer la zone",
"error.installWizard.message": "Une erreur s'est produite ; vous pouvez retourner en arrière et corriger les erreurs",
"error.invalid.username.password": "Identifiant ou mot de passe invalide",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "Az elem tulajdonságai megváltoztak",
"confirm.enable.s3": "Töltsd ki a következő információkat az S3 másodlagos tár bekapcsolásához!",
"confirm.enable.swift": "Töltsd ki a következő információkat a Swift támogatás bekapcsolásához!",
"error.could.not.change.your.password.because.ldap.is.enabled": "Nem sikerült megváltoztatni a jelszavadat, mert az LDAP be van kapcsolva.",
"error.could.not.change.your.password.because.non.native.user": "Nem sikerült megváltoztatni a jelszavadat, mert az LDAP be van kapcsolva.",
"error.could.not.enable.zone": "A zóna engedélyezése sikertelen",
"error.installWizard.message": "Valami nem sikerült, visszamehetsz kijavítani a hibákat.",
"error.invalid.username.password": "Érvénytelen felhasználónév vagy jelszó",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "Elementi delle proprietà modificati",
"confirm.enable.s3": "Si prega di inserire i valori richiesti per abilitare il supporto per il Secondary Storage di tipo S3",
"confirm.enable.swift": "Si prega di inserire i valori richiesti per abilitare il supporto per Swift",
"error.could.not.change.your.password.because.ldap.is.enabled": "Errore non è possibile cambiare la tua password perchè LDAP è abilitato.",
"error.could.not.change.your.password.because.non.native.user": "Errore non è possibile cambiare la tua password perchè LDAP è abilitato.",
"error.could.not.enable.zone": "Impossibile abilitare la zona",
"error.installWizard.message": "E' stato rilevato un errore: tornare agli step precedenti e correggere gli errori",
"error.invalid.username.password": "Username o Password non valida",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "項目のプロパティの変更",
"confirm.enable.s3": "S3 ベースのセカンダリ ストレージのサポートを有効にするには、次の情報を入力してください。",
"confirm.enable.swift": "Swift のサポートを有効にするには、次の情報を入力してください。",
"error.could.not.change.your.password.because.ldap.is.enabled": "エラー。LDAP が有効なためパスワードを変更できません。",
"error.could.not.change.your.password.because.non.native.user": "エラー。LDAP が有効なためパスワードを変更できません。",
"error.could.not.enable.zone": "ゾーンを有効にできませんでした",
"error.installWizard.message": "問題が発生しました。戻ってエラーを修正できます。",
"error.invalid.username.password": "無効なユーザー名またはパスワードです。",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "항목 속성 변경",
"confirm.enable.s3": "S3 기반 2차 저장소 지원을 하려면 아래 정보를 입력해 주십시오.",
"confirm.enable.swift": "Swift 기술 지원를 사용 하려면 다음 정보를 입력해 주십시오.",
"error.could.not.change.your.password.because.ldap.is.enabled": "LDAP 기능이 활성화 되어 있기 때문에 패스워드 변경을 실패하였습니다.",
"error.could.not.change.your.password.because.non.native.user": "LDAP 기능이 활성화 되어 있기 때문에 패스워드 변경을 실패하였습니다.",
"error.could.not.enable.zone": "Zone을 사용 할 수 없습니다.",
"error.installWizard.message": "문제가 발생했습니다. 다시 오류를 수정할 수 있습니다.",
"error.invalid.username.password": "유효하지 않은 사용자명 또는 암호",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "Endrede egenskaper",
"confirm.enable.s3": "Vennligst fyll inn følgende informasjon for å aktivere støtte for S3-støttet sekundærlagring",
"confirm.enable.swift": "Vennligst fyll inn følgende informasjon for å aktivere støtte for Swift",
"error.could.not.change.your.password.because.ldap.is.enabled": "Feil kunne ikke bytte ditt passord fordi LDAP er aktivert.",
"error.could.not.change.your.password.because.non.native.user": "Feil kunne ikke bytte ditt passord fordi LDAP er aktivert.",
"error.could.not.enable.zone": "Kunne ikke aktivere sonen",
"error.installWizard.message": "Noe gikk galt. Gå tilbake og korriger feilene.",
"error.invalid.username.password": "Ugyldig brukernavn eller passord",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "Item eigenschappen gewijzigd",
"confirm.enable.s3": "Vul de volgende informatie in om ondersteuning voor S3-aangestuurde Secundaire Opslag te activeren",
"confirm.enable.swift": "Vul de volgende informatie in om ondersteuning voor Swift te activeren",
"error.could.not.change.your.password.because.ldap.is.enabled": "Fout. Kan wachtwoord niet wijzigen omdat LDAP is uitgeschakeld.",
"error.could.not.change.your.password.because.non.native.user": "Fout. Kan wachtwoord niet wijzigen omdat LDAP is uitgeschakeld.",
"error.could.not.enable.zone": "Kon zone niet activeren",
"error.installWizard.message": "Er ging iets mis; je kunt teruggaan om de eventuele fouten te herstellen",
"error.invalid.username.password": "Ongeldige gebruikersnaam of wachtwoord",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "Changed item properties",
"confirm.enable.s3": "Please fill in the following information to enable support for S3-backed Secondary Storage",
"confirm.enable.swift": "Please fill in the following information to enable support for Swift",
"error.could.not.change.your.password.because.ldap.is.enabled": "Error could not change your password because LDAP is enabled.",
"error.could.not.change.your.password.because.non.native.user": "Error could not change your password because LDAP is enabled.",
"error.could.not.enable.zone": "Could not enable zone",
"error.installWizard.message": "Something went wrong; you may go back and correct any errors",
"error.invalid.username.password": "Błędna nazwa użytkownika lub hasło",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "Propriedades do item alteradas",
"confirm.enable.s3": "Por favor, preencha as informações abaixo para habilitar suporte o Storage Secundário fornecido por S3",
"confirm.enable.swift": "Por favor, preencha as informações abaixo para habilitar suporte ao Swift",
"error.could.not.change.your.password.because.ldap.is.enabled": "Erro: a nuvem não alterou sua senha porque o LDAP está ativo.",
"error.could.not.change.your.password.because.non.native.user": "Erro: a nuvem não alterou sua senha porque o LDAP está ativo.",
"error.could.not.enable.zone": "Não foi possível habilitar a zona",
"error.installWizard.message": "Alguma coisa está errada; você pode voltar e corrigir quaisquer erros",
"error.invalid.username.password": "Usuário ou senha inválidos",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "Параметры элемента изменены",
"confirm.enable.s3": "Заполните информацию для включения S3-совместимого дополнительного хранилища",
"confirm.enable.swift": "Заполните нижеследующую информацию для включения поддержи Swift",
"error.could.not.change.your.password.because.ldap.is.enabled": "Error could not change your password because LDAP is enabled.",
"error.could.not.change.your.password.because.non.native.user": "Error could not change your password because LDAP is enabled.",
"error.could.not.enable.zone": "Не удалось включить зону",
"error.installWizard.message": "Что-то не так. Вернитесь назад и исправьте ошибки.",
"error.invalid.username.password": "Неправильній логин или пароль",

View File

@ -20,7 +20,7 @@ var dictionary = {
"changed.item.properties": "更改项目属性",
"confirm.enable.s3": "请填写以下信息以启用对 S3 支持的二级存储的支持",
"confirm.enable.swift": "请填写以下信息以启用对 SWIFT 的支持",
"error.could.not.change.your.password.because.ldap.is.enabled": "错误。LDAP 处于启用状态,无法更改您的密码。",
"error.could.not.change.your.password.because.non.native.user": "错误。LDAP 处于启用状态,无法更改您的密码。",
"error.could.not.enable.zone": "无法启用资源域",
"error.installWizard.message": "出现问题;请返回并更正任何错误",
"error.invalid.username.password": "用户名或密码无效",

View File

@ -1267,9 +1267,8 @@
var complete = args.complete;
var context = args.context;
if (isLdapEnabled()) {
cloudStack.dialog.notice({ message: _l('error.could.not.change.your.password.because.ldap.is.enabled') });
} else {
var userSource = context.users[0].usersource;
if (userSource == "native") {
cloudStack.dialog.createForm({
form: {
title: 'label.action.change.password',
@ -1316,6 +1315,8 @@
});
}
});
} else {
cloudStack.dialog.notice({ message: _l('error.could.not.change.your.password.because.non.native.user') });
}
}
}