Skip to content

Conversation

@yadvr
Copy link
Member

@yadvr yadvr commented Jun 24, 2020

This will purge all the cookies on logout including multiple sessionkey
cookies if passed. On login, this will restrict sessionkey cookie
(httponly) to the /client path like the JSESSIONID cookie.

Fixes #4136

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Needs manual testing

This will purge all the cookies on logout including multiple sessionkey
cookies if passed. On login, this will restrict sessionkey cookie
(httponly) to the /client path like the JSESSIONID cookie.

Fixes apache#4136

Signed-off-by: Rohit Yadav <[email protected]>
@yadvr yadvr added this to the 4.13.2.0 milestone Jun 24, 2020
@yadvr yadvr requested a review from andrijapanicsb June 24, 2020 17:02
@yadvr
Copy link
Member Author

yadvr commented Jun 24, 2020

Please review and test @davidjumani @shwstppr cc @Pearl1594

@yadvr
Copy link
Member Author

yadvr commented Jun 24, 2020

@blueorangutan package

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

responseString = apiAuthenticator.authenticate(command, params, session, remoteAddress, responseType, auditTrailSb, req, resp);
if (session != null && session.getAttribute(ApiConstants.SESSIONKEY) != null) {
resp.addHeader("SET-COOKIE", String.format("%s=%s;HttpOnly", ApiConstants.SESSIONKEY, session.getAttribute(ApiConstants.SESSIONKEY)));
resp.addHeader("SET-COOKIE", String.format("%s=%s;HttpOnly;Path=/client", ApiConstants.SESSIONKEY, session.getAttribute(ApiConstants.SESSIONKEY)));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check if this is necessary or not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidjumani please explore if this would work, without adding the /client path to the cookie; as I worry if this change can potentially break non-standard env (those which don't use the default context path of /client as defined in /etc/cloudstack/management/server.properties)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is necessary, if not present, two sessionkeys are present
If non-standard implementations are the case, wouldn't JSESSIONID cause issues too?
Also exploring saml logins

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidjumani in a deploy trillian env with this PR (or you may use the primate-qa server as well which has this PR) and both old UI and Primate, can you check side-effects when you change the context in /etc/cloudstack/management/server.properties from /client/ to say (a) /somenew-path and (b) / and restart management server and try log-in in both legacy UI and Primate (check network an Application/cookies)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind I tested, this will break if path is restricted to /client only; ideally shoud match the webapp context path

@yadvr yadvr changed the base branch from master to 4.13 June 24, 2020 17:21
@apache apache deleted a comment from blueorangutan Jun 24, 2020
@yadvr
Copy link
Member Author

yadvr commented Jun 24, 2020

@blueorangutan package

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✖centos7 ✖debian. JID-1452

sessionKeyCookie.setMaxAge(0);
resp.addCookie(sessionKeyCookie);
final Cookie[] cookies = req.getCookies();
if (cookies != null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhtyd missing brace

@yadvr
Copy link
Member Author

yadvr commented Jun 24, 2020

@blueorangutan package

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✔debian. JID-1453

@yadvr
Copy link
Member Author

yadvr commented Jun 24, 2020

@blueorangutan test

@blueorangutan
Copy link

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@yadvr
Copy link
Member Author

yadvr commented Jun 25, 2020

@blueorangutan package

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✖debian. JID-1462

@davidjumani
Copy link
Contributor

Tested for local / saml users. LGTM

@yadvr
Copy link
Member Author

yadvr commented Jun 26, 2020

@davidjumani did you also test changing the context path from server properties?

@davidjumani
Copy link
Contributor

davidjumani commented Jun 26, 2020

Works when the context path is changed to /something but fails when just set to /

Copy link
Contributor

@Pearl1594 Pearl1594 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This PR addresses the core issue of handling multiple session keys (closing #4166)

@yadvr
Copy link
Member Author

yadvr commented Jul 4, 2020

@blueorangutan package

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✔debian. JID-1531

@yadvr
Copy link
Member Author

yadvr commented Jul 4, 2020

@blueorangutan test

@blueorangutan
Copy link

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@yadvr
Copy link
Member Author

yadvr commented Jul 5, 2020

@blueorangutan test

@blueorangutan
Copy link

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@yadvr
Copy link
Member Author

yadvr commented Jul 6, 2020

@blueorangutan test

@blueorangutan
Copy link

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@yadvr
Copy link
Member Author

yadvr commented Jul 6, 2020

@davidjumani can you help review/test/fix, thnx

@yadvr
Copy link
Member Author

yadvr commented Jul 7, 2020

@Pearl1594 @davidjumani any progress on this?

@Pearl1594
Copy link
Contributor

@blueorangutan package

@Pearl1594
Copy link
Contributor

@rhtyd looking into it

@blueorangutan
Copy link

@Pearl1594 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✔debian. JID-1551

@Pearl1594
Copy link
Contributor

@rhtyd it works now - for both changing context.path to a value other that /client and for /
Have to test it for SAML login

@Pearl1594
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@Pearl1594 a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-2026)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 28097 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4176-t2026-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_privategw_acl.py
Smoke tests completed. 76 look OK, 1 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File
test_02_vpc_privategw_static_routes Failure 176.97 test_privategw_acl.py
test_03_vpc_privategw_restart_vpc_cleanup Failure 176.08 test_privategw_acl.py
test_04_rvpc_privategw_static_routes Failure 245.60 test_privategw_acl.py

@apache apache deleted a comment from blueorangutan Jul 8, 2020
@apache apache deleted a comment from blueorangutan Jul 8, 2020
@apache apache deleted a comment from blueorangutan Jul 8, 2020
@apache apache deleted a comment from blueorangutan Jul 8, 2020
@yadvr
Copy link
Member Author

yadvr commented Jul 8, 2020

Tests lgtm

@yadvr yadvr merged commit 139aa13 into apache:4.13 Jul 8, 2020
shwstppr pushed a commit to shapeblue/cloudstack that referenced this pull request Jul 8, 2020
…e#4176)

This will purge all the cookies on logout including multiple sessionkey
cookies if passed. On login, this will restrict sessionkey cookie
(httponly) to the / path.

Fixes apache#4136

Co-authored-by: Pearl Dsilva <[email protected]>
shwstppr pushed a commit to shapeblue/cloudstack that referenced this pull request Jul 8, 2020
…e#4176)

This will purge all the cookies on logout including multiple sessionkey
cookies if passed. On login, this will restrict sessionkey cookie
(httponly) to the / path.

Fixes apache#4136

Co-authored-by: Pearl Dsilva <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI doesn't allow login if sessionkey and JSESSIONID cookies are deleted

5 participants