|
66 | 66 | import org.apache.cloudstack.api.ResponseObject; |
67 | 67 | import org.apache.cloudstack.api.ResponseObject.ResponseView; |
68 | 68 | import org.apache.cloudstack.api.ServerApiException; |
| 69 | +import org.apache.cloudstack.api.auth.APIAuthenticationManager; |
69 | 70 | import org.apache.cloudstack.api.command.admin.account.ListAccountsCmdByAdmin; |
70 | 71 | import org.apache.cloudstack.api.command.admin.host.ListHostsCmd; |
71 | 72 | import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd; |
@@ -204,6 +205,8 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer |
204 | 205 | private ConfigurationDao _configDao; |
205 | 206 | @Inject |
206 | 207 | private EntityManager _entityMgr; |
| 208 | + @Inject |
| 209 | + APIAuthenticationManager _authManager; |
207 | 210 |
|
208 | 211 | List<PluggableService> _pluggableServices; |
209 | 212 | List<APIChecker> _apiAccessCheckers; |
@@ -485,6 +488,10 @@ public String handleRequest(final Map params, final String responseType, final S |
485 | 488 | } |
486 | 489 | throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "Invalid request, no command sent"); |
487 | 490 | } else { |
| 491 | + // Don't allow Login/Logout APIs to go past this point |
| 492 | + if (_authManager.getAPIAuthenticator(command[0]) != null) { |
| 493 | + return null; |
| 494 | + } |
488 | 495 | final Map<String, String> paramMap = new HashMap<String, String>(); |
489 | 496 | final Set keys = params.keySet(); |
490 | 497 | final Iterator keysIter = keys.iterator(); |
@@ -522,12 +529,10 @@ public String handleRequest(final Map params, final String responseType, final S |
522 | 529 | else |
523 | 530 | buildAuditTrail(auditTrailSb, command[0], response); |
524 | 531 | } else { |
525 | | - if (!command[0].equalsIgnoreCase("login") && !command[0].equalsIgnoreCase("logout")) { |
526 | | - final String errorString = "Unknown API command: " + command[0]; |
527 | | - s_logger.warn(errorString); |
528 | | - auditTrailSb.append(" " + errorString); |
529 | | - throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, errorString); |
530 | | - } |
| 532 | + final String errorString = "Unknown API command: " + command[0]; |
| 533 | + s_logger.warn(errorString); |
| 534 | + auditTrailSb.append(" " + errorString); |
| 535 | + throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, errorString); |
531 | 536 | } |
532 | 537 | } |
533 | 538 | } catch (final InvalidParameterValueException ex) { |
|
0 commit comments