CLOUDSTACK-10327: Do not invalidate the session when API command not found - #2498
Conversation
5884034 to
14ae40a
Compare
|
@olivierlemasle can you edit the PR and rebase against 4.11 branch? I tried to do that, but Github requires rebasing against 4.11. |
14ae40a to
06590a2
Compare
06590a2 to
ee47f45
Compare
|
@rhtyd Ok, I've rebased the PR against 4.11 and updated the base branch accordingly. |
| throw new ServerApiException(ApiErrorCode.API_LIMIT_EXCEED, ex.getMessage()); | ||
| } catch (final UnavailableCommandException ex) { | ||
| s_logger.debug(ex.getMessage()); | ||
| throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, ex.getMessage()); |
There was a problem hiding this comment.
Why not throw ServerApiException with suitable http error code so as to not cause log out in the UI. Simply handle permission denied exception here? (or the line below)
There was a problem hiding this comment.
@rhtyd I'm not sure I understand your suggestion. The Http error code is specified here, in line 964). The ServerApiException is caught on ApiServlet which generates the HTTP response.
|
Thanks @olivierlemasle. I've one comment, since the last change around this was made by Wido, let's ask @wido for review. |
|
I don't see anything odd in this PR, looks good to me. I didn't catch this situation. |
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✖debian. JID-1818 |
|
@blueorangutan test |
|
@borisstoyanov a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-2449)
|
|
@blueorangutan test |
|
@borisstoyanov a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-2456)
|
|
@borisstoyanov here we also have that same |
|
Merged based on test results and code review. |
Description
CloudStack SSO (using
security.singlesignon.key) does not work anymore with CloudStack 4.11, since commit 9988c26, which introduced a regression due to a refactoring: every API request that is not "validated" generates the same error (401 - Unauthorized) and invalidates the session.However, CloudStack UI executes a call to
listConfigurationsin methodbypassLoginCheck. A non-admin user does not have the permissions to execute this request, which causes an error 401:The session (already created by SSO) is then invalidated and the user cannot access to CloudStack UI (error "Session Expired").
Before 9988c26 (up to CloudStack 4.10), an error 432 was returned (and ignored):
Even if the call to
listConfigurationswas removed, another call tolistIdpsalso lead to an error 401 for user accounts if the SAML plugin is not enabled.This pull request aims to fix the SSO issue, by restoring errors 432 (instead of 401 + invalidate session) for commands not available. However, if an API command is explicitly denied using ACLs or if the session key is incorrect, it still generates an error 401 and invalidates the session.
Types of changes
How Has This Been Tested?
Compiled and ran CloudStack.
listConfigurationsfor a user) generate 432.listIdpswith SAML disabled) generate 432.fooBar) generate 432However, API calls with session key removed generate 401 and invalidate session.
SSO is ok.
Checklist: