Skip to content

Commit 2493a59

Browse files
committed
server,cks: skip password policy if create account and user by system account
1 parent 1c0182f commit 2493a59

File tree

14 files changed

+25
-23
lines changed

14 files changed

+25
-23
lines changed

api/src/main/java/com/cloud/user/AccountService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ public interface AccountService {
4646
UserAccount createUserAccount(CreateAccountCmd accountCmd);
4747

4848
UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, Account.Type accountType,
49-
Long roleId, Long domainId, String networkDomain, Map<String, String> details, String accountUUID, String userUUID, User.Source source);
50-
49+
Long roleId, Long domainId, String networkDomain, Map<String, String> details, String accountUUID, String userUUID, User.Source source, Account caller);
5150
/**
5251
* Locks a user by userId. A locked user cannot access the API, but will still have running VMs/IP addresses
5352
* allocated/etc.

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ protected Account createProjectKubernetesAccount(final Project project, final St
15531553
UserAccount userAccount = accountService.createUserAccount(accountName,
15541554
UUID.randomUUID().toString(), PROJECT_KUBERNETES_ACCOUNT_FIRST_NAME,
15551555
PROJECT_KUBERNETES_ACCOUNT_LAST_NAME, null, null, accountName, Account.Type.NORMAL, role.getId(),
1556-
project.getDomainId(), null, null, null, null, User.Source.NATIVE);
1556+
project.getDomainId(), null, null, null, null, User.Source.NATIVE, accountService.getSystemAccount());
15571557
projectManager.assignAccountToProject(project, userAccount.getAccountId(), ProjectAccount.Role.Regular,
15581558
userAccount.getId(), null);
15591559
Account account = accountService.getAccount(userAccount.getAccountId());

plugins/network-elements/juniper-contrail/src/test/java/org/apache/cloudstack/network/contrail/management/MockAccountManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ public UserAccount createUserAccount(CreateAccountCmd cmd) {
147147
cmd.getLastName(), cmd.getEmail(), cmd.getTimeZone(), cmd.getAccountName(),
148148
cmd.getAccountType(), cmd.getRoleId(), cmd.getDomainId(),
149149
cmd.getNetworkDomain(), cmd.getDetails(), cmd.getAccountUUID(),
150-
cmd.getUserUUID(), User.Source.UNKNOWN);
150+
cmd.getUserUUID(), User.Source.UNKNOWN, null);
151151
}
152152

153153
@Override
154154
public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, Account.Type accountType, Long roleId,
155-
Long domainId, String networkDomain, Map<String, String> details, String accountUUID, String userUUID, User.Source source) {
155+
Long domainId, String networkDomain, Map<String, String> details, String accountUUID, String userUUID, User.Source source, Account caller) {
156156
// TODO Auto-generated method stub
157157
return null;
158158
}

plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/command/LdapCreateAccountCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ UserAccount createCloudstackUserAccount(final LdapUser user, String accountName,
9595
Account account = _accountService.getActiveAccountByName(accountName, domainId);
9696
if (account == null) {
9797
return _accountService.createUserAccount(username, generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, getAccountType(), getRoleId(),
98-
domainId, networkDomain, details, accountUUID, userUUID, User.Source.LDAP);
98+
domainId, networkDomain, details, accountUUID, userUUID, User.Source.LDAP, null);
9999
} else {
100100
User newUser = _accountService.createUser(username, generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, domainId,
101101
userUUID, User.Source.LDAP);

plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/command/LdapImportUsersCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private void createCloudstackUserAccount(LdapUser user, String accountName, Doma
108108
if (account == null) {
109109
logger.debug("No account exists with name: " + accountName + " creating the account and an user with name: " + user.getUsername() + " in the account");
110110
_accountService.createUserAccount(user.getUsername(), generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, getAccountType(), getRoleId(),
111-
domain.getId(), domain.getNetworkDomain(), details, UUID.randomUUID().toString(), UUID.randomUUID().toString(), User.Source.LDAP);
111+
domain.getId(), domain.getNetworkDomain(), details, UUID.randomUUID().toString(), UUID.randomUUID().toString(), User.Source.LDAP, null);
112112
} else {
113113
// check if the user exists. if yes, call update
114114
UserAccount csuser = _accountService.getActiveUserAccount(user.getUsername(), domain.getId());

plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/command/LinkAccountToLdapCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void execute() throws ServerApiException {
8989
try {
9090
UserAccount userAccount = _accountService
9191
.createUserAccount(admin, "", ldapUser.getFirstname(), ldapUser.getLastname(), ldapUser.getEmail(), null, admin, Account.Type.DOMAIN_ADMIN, RoleType.DomainAdmin.getId(), domainId, null, null, UUID.randomUUID().toString(),
92-
UUID.randomUUID().toString(), User.Source.LDAP);
92+
UUID.randomUUID().toString(), User.Source.LDAP, null);
9393
response.setAdminId(String.valueOf(userAccount.getAccountId()));
9494
logger.info("created an account with name {} in the given domain {} with id {}", admin, _domainService.getDomain(domainId), domainId);
9595
} catch (Exception e) {

plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/command/LinkDomainToLdapCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void execute() throws ServerApiException {
105105
if (account == null) {
106106
try {
107107
UserAccount userAccount = _accountService.createUserAccount(admin, "", ldapUser.getFirstname(), ldapUser.getLastname(), ldapUser.getEmail(), null,
108-
admin, Account.Type.DOMAIN_ADMIN, RoleType.DomainAdmin.getId(), domainId, null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), User.Source.LDAP);
108+
admin, Account.Type.DOMAIN_ADMIN, RoleType.DomainAdmin.getId(), domainId, null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), User.Source.LDAP, null);
109109
response.setAdminId(String.valueOf(userAccount.getAccountId()));
110110
logger.info("created an account with name {} in the given domain {} with id {}", admin, _domainService.getDomain(domainId), domainId);
111111
} catch (Exception e) {

plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapAuthenticator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ private void createCloudStackUserAccount(LdapUser user, long domainId, Account.T
310310
String username = user.getUsername();
311311
_accountManager.createUserAccount(username, "", user.getFirstname(), user.getLastname(), user.getEmail(), null, username,
312312
accountType, RoleType.getByAccountType(accountType).getId(), domainId, null, null,
313-
UUID.randomUUID().toString(), UUID.randomUUID().toString(), User.Source.LDAP);
313+
UUID.randomUUID().toString(), UUID.randomUUID().toString(), User.Source.LDAP, null);
314314
}
315315

316316
private void disableUserInCloudStack(UserAccount user) {

plugins/user-authenticators/ldap/src/test/groovy/org/apache/cloudstack/ldap/LdapAuthenticatorSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class LdapAuthenticatorSpec extends spock.lang.Specification {
176176
ldapManager.getUser(username, type.toString(), name) >> new LdapUser(username, "email", "firstname", "lastname", "principal", "domain", false, null)
177177
ldapManager.canAuthenticate(_, _, _) >> true
178178
//user should be created in cloudstack
179-
accountManager.createUserAccount(username, "", "firstname", "lastname", "email", null, username, (short) 2, domainId, username, null, _, _, User.Source.LDAP) >> Mock(UserAccount)
179+
accountManager.createUserAccount(username, "", "firstname", "lastname", "email", null, username, (short) 2, domainId, username, null, _, _, User.Source.LDAP, null) >> Mock(UserAccount)
180180

181181
when:
182182
Pair<Boolean, UserAuthenticator.ActionOnFailedAuthentication> result = ldapAuthenticator.authenticate(username, "password", domainId, null)

plugins/user-authenticators/ldap/src/test/groovy/org/apache/cloudstack/ldap/LdapImportUsersCmdSpec.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ class LdapImportUsersCmdSpec extends spock.lang.Specification {
213213
def accountService = Mock(AccountService)
214214
1 * accountService.getActiveAccountByName('ACCOUNT', 0) >> Mock(AccountVO)
215215

216-
1 * accountService.createUser('rmurphy', _ , 'Ryan', 'Murphy', '[email protected]', null, 'ACCOUNT', 0, _, User.Source.LDAP) >> Mock(UserVO)
217-
0 * accountService.createUserAccount('rmurphy', _, 'Ryan', 'Murphy', '[email protected]', null, 'ACCOUNT', 2, 0, 'DOMAIN', null, _, _, User.Source.LDAP)
216+
1 * accountService.createUser('rmurphy', _ , 'Ryan', 'Murphy', '[email protected]', null, 'ACCOUNT', 0, _, User.Source.LDAP, null) >> Mock(UserVO)
217+
0 * accountService.createUserAccount('rmurphy', _, 'Ryan', 'Murphy', '[email protected]', null, 'ACCOUNT', 2, 0, 'DOMAIN', null, _, _, User.Source.LDAP, null)
218218
0 * accountService.updateUser(_,'Ryan', 'Murphy', '[email protected]', null, null, null, null, null);
219219

220220
def ldapImportUsersCmd = new LdapImportUsersCmd(ldapManager, domainService, accountService)

0 commit comments

Comments
 (0)