Skip to content

Commit f253fd0

Browse files
authored
Merge branch 'main' into dependabot/maven/com.zaxxer-HikariCP-7.0.2
2 parents c41fc90 + 10d76d3 commit f253fd0

File tree

9 files changed

+161
-14
lines changed

9 files changed

+161
-14
lines changed

.github/workflows/stale.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: 'Close stale issues and PRs'
19+
on:
20+
schedule:
21+
- cron: '30 1 * * *'
22+
23+
jobs:
24+
stale:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
actions: write
28+
issues: write
29+
pull-requests: write
30+
steps:
31+
- uses: actions/stale@v10
32+
with:
33+
stale-issue-message: 'This issue is stale because it has been open for 120 days with no activity. It may be removed by administrators of this project at any time. Remove the stale label or comment to request for removal of it to prevent this.'
34+
stale-pr-message: 'This PR is stale because it has been open for 120 days with no activity. It may be removed by administrators of this project at any time. Remove the stale label or comment to request for removal of it to prevent this.'
35+
close-issue-message: 'This issue was closed because it has been stale for 120 days with no activity.'
36+
close-pr-message: 'This PR was closed because it has been stale for 120 days with no activity.'
37+
stale-issue-label: 'no-issue-activity'
38+
stale-pr-label: 'no-pr-activity'
39+
days-before-stale: 120
40+
exempt-issue-labels: 'gsoc,good-first-issue,long-term-plan'
41+
exempt-pr-labels: 'status:ready-for-merge,status:needs-testing,status:on-hold'

plugins/user-authenticators/ldap/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,11 @@
215215
<artifactId>commons-io</artifactId>
216216
<version>${cs.commons-io.version}</version>
217217
</dependency>
218+
<dependency>
219+
<groupId>org.apache.cloudstack</groupId>
220+
<artifactId>cloud-api</artifactId>
221+
<version>${project.version}</version>
222+
<scope>compile</scope>
223+
</dependency>
218224
</dependencies>
219225
</project>

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,10 @@ public class LinkDomainToLdapCmd extends BaseCmd {
5151
@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, required = true, description = "type of the ldap name. GROUP or OU")
5252
private String type;
5353

54-
@Parameter(name = ApiConstants.LDAP_DOMAIN, type = CommandType.STRING, required = false, description = "name of the group or OU in LDAP")
54+
@Parameter(name = ApiConstants.LDAP_DOMAIN, type = CommandType.STRING, required = true, description = "name of the group or OU in LDAP")
5555
private String ldapDomain;
5656

57-
@Deprecated
58-
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = false, description = "name of the group or OU in LDAP")
59-
private String name;
60-
61-
@Parameter(name = ApiConstants.ADMIN, type = CommandType.STRING, required = false, description = "domain admin username in LDAP ")
57+
@Parameter(name = ApiConstants.ADMIN, type = CommandType.STRING, description = "domain admin username in LDAP ")
6258
private String admin;
6359

6460
@Parameter(name = ApiConstants.ACCOUNT_TYPE, type = CommandType.INTEGER, required = true, description = "Type of the account to auto import. Specify 0 for user and 2 for " +
@@ -77,7 +73,7 @@ public String getType() {
7773
}
7874

7975
public String getLdapDomain() {
80-
return ldapDomain == null ? name : ldapDomain;
76+
return ldapDomain;
8177
}
8278

8379
public String getAdmin() {
@@ -98,7 +94,7 @@ public void execute() throws ServerApiException {
9894
try {
9995
ldapUser = _ldapManager.getUser(admin, type, getLdapDomain(), domainId);
10096
} catch (NoLdapUserMatchingQueryException e) {
101-
logger.debug("no ldap user matching username " + admin + " in the given group/ou", e);
97+
logger.debug("no ldap user matching username {} in the given group/ou", admin, e);
10298
}
10399
if (ldapUser != null && !ldapUser.isDisabled()) {
104100
Account account = _accountService.getActiveAccountByName(admin, domainId);
@@ -115,7 +111,7 @@ public void execute() throws ServerApiException {
115111
logger.debug("an account with name {} already exists in the domain {} with id {}", admin, _domainService.getDomain(domainId), domainId);
116112
}
117113
} else {
118-
logger.debug("ldap user with username "+admin+" is disabled in the given group/ou");
114+
logger.debug("ldap user with username {} is disabled in the given group/ou", admin);
119115
}
120116
}
121117
response.setObjectName("LinkDomainToLdap");
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.cloudstack.api.command;
20+
21+
import com.cloud.exception.ConcurrentOperationException;
22+
import com.cloud.exception.InsufficientCapacityException;
23+
import com.cloud.exception.NetworkRuleConflictException;
24+
import com.cloud.exception.ResourceAllocationException;
25+
import com.cloud.exception.ResourceUnavailableException;
26+
import com.cloud.user.Account;
27+
import org.apache.cloudstack.api.APICommand;
28+
import org.apache.cloudstack.api.ApiConstants;
29+
import org.apache.cloudstack.api.BaseCmd;
30+
import org.apache.cloudstack.api.Parameter;
31+
import org.apache.cloudstack.api.ServerApiException;
32+
import org.apache.cloudstack.api.response.SuccessResponse;
33+
import org.apache.cloudstack.api.response.DomainResponse;
34+
import org.apache.cloudstack.ldap.LdapManager;
35+
36+
import javax.inject.Inject;
37+
38+
@APICommand(name = "unlinkDomainFromLdap", description = "remove the linkage of a Domain to a group or OU in ldap",
39+
responseObject = SuccessResponse.class, since = "4.23.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
40+
public class UnlinkDomainFromLdapCmd extends BaseCmd {
41+
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = true, entityType = DomainResponse.class,
42+
description = "The ID of the Domain which has to be unlinked from LDAP.")
43+
private Long domainId;
44+
45+
@Inject
46+
private LdapManager _ldapManager;
47+
48+
public Long getDomainId() {
49+
return domainId;
50+
}
51+
52+
@Override
53+
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
54+
boolean rc = _ldapManager.unlinkDomainFromLdap(this);
55+
SuccessResponse response = new SuccessResponse(getCommandName());
56+
response.setSuccess(rc);
57+
if (rc) {
58+
response.setDisplayText("Domain unlinked from LDAP successfully");
59+
} else {
60+
response.setDisplayText("Failed to unlink domain from LDAP");
61+
}
62+
setResponseObject(response);
63+
}
64+
65+
@Override
66+
public long getEntityOwnerId() {
67+
return Account.ACCOUNT_ID_SYSTEM;
68+
}
69+
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.cloudstack.api.command.LdapListConfigurationCmd;
2424
import org.apache.cloudstack.api.command.LinkAccountToLdapCmd;
2525
import org.apache.cloudstack.api.command.LinkDomainToLdapCmd;
26+
import org.apache.cloudstack.api.command.UnlinkDomainFromLdapCmd;
2627
import org.apache.cloudstack.api.response.LdapConfigurationResponse;
2728
import org.apache.cloudstack.api.response.LdapUserResponse;
2829

@@ -34,7 +35,7 @@
3435

3536
public interface LdapManager extends PluggableService {
3637

37-
enum LinkType { GROUP, OU;}
38+
enum LinkType { GROUP, OU}
3839

3940
LdapConfigurationResponse addConfiguration(final LdapAddConfigurationCmd cmd) throws InvalidParameterValueException;
4041

@@ -69,6 +70,8 @@ enum LinkType { GROUP, OU;}
6970

7071
LinkDomainToLdapResponse linkDomainToLdap(LinkDomainToLdapCmd cmd);
7172

73+
boolean unlinkDomainFromLdap(UnlinkDomainFromLdapCmd cmd);
74+
7275
LdapTrustMapVO getDomainLinkedToLdap(long domainId);
7376

7477
List<LdapTrustMapVO> getDomainLinkage(long domainId);

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.apache.cloudstack.api.command.LdapUserSearchCmd;
4444
import org.apache.cloudstack.api.command.LinkAccountToLdapCmd;
4545
import org.apache.cloudstack.api.command.LinkDomainToLdapCmd;
46+
import org.apache.cloudstack.api.command.UnlinkDomainFromLdapCmd;
4647
import org.apache.cloudstack.api.response.LdapConfigurationResponse;
4748
import org.apache.cloudstack.api.response.LdapUserResponse;
4849
import org.apache.cloudstack.api.response.LinkAccountToLdapResponse;
@@ -292,7 +293,7 @@ private LdapConfigurationResponse deleteConfigurationInternal(final String hostn
292293

293294
@Override
294295
public List<Class<?>> getCommands() {
295-
final List<Class<?>> cmdList = new ArrayList<Class<?>>();
296+
final List<Class<?>> cmdList = new ArrayList<>();
296297
cmdList.add(LdapUserSearchCmd.class);
297298
cmdList.add(LdapListUsersCmd.class);
298299
cmdList.add(LdapAddConfigurationCmd.class);
@@ -304,6 +305,7 @@ public List<Class<?>> getCommands() {
304305
cmdList.add(LDAPRemoveCmd.class);
305306
cmdList.add(LinkDomainToLdapCmd.class);
306307
cmdList.add(LinkAccountToLdapCmd.class);
308+
cmdList.add(UnlinkDomainFromLdapCmd.class);
307309
return cmdList;
308310
}
309311

@@ -393,7 +395,7 @@ public Pair<List<? extends LdapConfigurationVO>, Integer> listConfigurations(fin
393395
final boolean listAll = cmd.listAll();
394396
final Long id = cmd.getId();
395397
final Pair<List<LdapConfigurationVO>, Integer> result = _ldapConfigurationDao.searchConfigurations(id, hostname, port, domainId, listAll);
396-
return new Pair<List<? extends LdapConfigurationVO>, Integer>(result.first(), result.second());
398+
return new Pair<>(result.first(), result.second());
397399
}
398400

399401
@Override
@@ -423,6 +425,11 @@ public LinkDomainToLdapResponse linkDomainToLdap(LinkDomainToLdapCmd cmd) {
423425
return linkDomainToLdap(cmd.getDomainId(),cmd.getType(), ldapDomain,cmd.getAccountType());
424426
}
425427

428+
@Override
429+
public boolean unlinkDomainFromLdap(UnlinkDomainFromLdapCmd cmd) {
430+
return unlinkDomainFromLdap(cmd.getDomainId());
431+
}
432+
426433
private LinkDomainToLdapResponse linkDomainToLdap(Long domainId, String type, String name, Account.Type accountType) {
427434
Validate.notNull(type, "type cannot be null. It should either be GROUP or OU");
428435
Validate.notNull(domainId, "domainId cannot be null.");
@@ -442,6 +449,15 @@ private LinkDomainToLdapResponse linkDomainToLdap(Long domainId, String type, St
442449
return response;
443450
}
444451

452+
private boolean unlinkDomainFromLdap(Long domainId) {
453+
LdapTrustMapVO vo = _ldapTrustMapDao.findByDomainId(domainId);
454+
if (vo != null) {
455+
removeTrustmap(vo);
456+
return true;
457+
}
458+
return false;
459+
}
460+
445461
@Override
446462
public LdapTrustMapVO getDomainLinkedToLdap(long domainId){
447463
return _ldapTrustMapDao.findByDomainId(domainId);

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
<cs.amqp-client.version>5.17.0</cs.amqp-client.version>
127127
<cs.apache-cloudstack-java-client.version>1.0.9</cs.apache-cloudstack-java-client.version>
128128
<cs.aspectjrt.version>1.9.19</cs.aspectjrt.version>
129-
<cs.aws.sdk.version>1.12.439</cs.aws.sdk.version>
129+
<cs.aws.sdk.version>1.12.795</cs.aws.sdk.version>
130130
<cs.axiom.version>1.2.8</cs.axiom.version>
131131
<cs.axis2.version>1.6.4</cs.axis2.version>
132132
<cs.batik.version>1.14</cs.batik.version>

ui/public/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,7 @@
14521452
"label.lbruleid": "Load balancer ID",
14531453
"label.lbtype": "Load balancer type",
14541454
"label.ldap": "LDAP",
1455+
"label.ldapdomain": "LDAP Domain",
14551456
"label.ldap.configuration": "LDAP Configuration",
14561457
"label.ldap.group.name": "LDAP Group",
14571458
"label.level": "Level",
@@ -2587,6 +2588,7 @@
25872588
"label.undefined": "Undefined",
25882589
"label.unit": "Usage unit",
25892590
"label.unknown": "Unknown",
2591+
"label.unlink.domain.from.ldap": "Unlink the Domain from LDAP",
25902592
"label.unlimited": "Unlimited",
25912593
"label.unmanaged": "Unmanaged",
25922594
"label.unmanage.instance": "Unmanage Instance",

ui/src/config/section/domain.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default {
144144
docHelp: 'adminguide/accounts.html#using-an-ldap-server-for-user-authentication',
145145
listView: true,
146146
dataView: true,
147-
args: ['type', 'domainid', 'name', 'accounttype', 'admin'],
147+
args: ['type', 'domainid', 'ldapdomain', 'accounttype', 'admin'],
148148
mapping: {
149149
type: {
150150
options: ['GROUP', 'OU']
@@ -157,6 +157,20 @@ export default {
157157
}
158158
}
159159
},
160+
{
161+
api: 'unlinkDomainFromLdap',
162+
icon: 'ArrowsAltOutlined',
163+
label: 'label.unlink.domain.from.ldap',
164+
docHelp: 'adminguide/accounts.html#using-an-ldap-server-for-user-authentication',
165+
listView: true,
166+
dataView: true,
167+
args: ['domainid'],
168+
mapping: {
169+
domainid: {
170+
value: (record) => { return record.id }
171+
}
172+
}
173+
},
160174
{
161175
api: 'deleteDomain',
162176
icon: 'delete-outlined',

0 commit comments

Comments
 (0)