Skip to content

Conversation

@AndrewHaZG
Copy link
Contributor

Description

Fixes #11078

This PR extends the logout function to improve cookie cleanup by removing cookies for multiple paths and domains to ensure complete session termination.

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)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@boring-cyborg
Copy link

boring-cyborg bot commented Jul 31, 2025

Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
Here are some useful points:

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the logout function to prevent session issues by implementing more comprehensive cookie cleanup. The change addresses incomplete session termination by ensuring cookies are removed across multiple paths and domains.

Key Changes

  • Replaces basic cookie removal with systematic cleanup across multiple paths (/ and /client)
  • Adds domain-specific cookie removal for current hostname and its subdomain variant
  • Implements nested loops to ensure all cookie combinations are properly cleared

}).finally(() => {
const paths = ['/', '/client']
const hostname = window.location.hostname
const domains = [undefined, hostname, `.${hostname}`]
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The domain .${hostname} may create an invalid domain format. For example, if hostname is 'localhost' or an IP address like '127.0.0.1', the resulting domain '.localhost' or '.127.0.0.1' would be invalid. Consider validating the hostname format before adding the dot prefix, or handle cases where the hostname might not be a valid domain.

Suggested change
const domains = [undefined, hostname, `.${hostname}`]
const isValidDomain = (name) => /^[a-zA-Z0-9.-]+$/.test(name) && !/^(\d{1,3}\.){3}\d{1,3}$/.test(name) && name !== 'localhost'
const domains = [undefined, hostname]
if (isValidDomain(hostname)) {
domains.push(`.${hostname}`)
}

Copilot uses AI. Check for mistakes.
Comment on lines 502 to 508
Object.keys(Cookies.get()).forEach(cookieName => {
Cookies.remove(cookieName)
Cookies.remove(cookieName, { path: '/client' })
paths.forEach(path => {
domains.forEach(domain => {
const options = { path }
if (domain) options.domain = domain
Cookies.remove(cookieName, options)
})
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

Using nested forEach loops results in O(nmk) complexity where n is the number of cookies, m is the number of paths, and k is the number of domains. This could be inefficient if there are many cookies. Consider batching the operations or using a more efficient approach for cookie removal.

Copilot uses AI. Check for mistakes.
@sureshanaparti
Copy link
Contributor

@blueorangutan ui

@blueorangutan
Copy link

@sureshanaparti a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@codecov
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 3.64%. Comparing base (1f1e38f) to head (5c44461).
⚠️ Report is 9 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (1f1e38f) and HEAD (5c44461). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (1f1e38f) HEAD (5c44461)
unittests 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##               main   #11359       +/-   ##
=============================================
- Coverage     17.17%    3.64%   -13.53%     
=============================================
  Files          5869      441     -5428     
  Lines        521732    36822   -484910     
  Branches      63511     6736    -56775     
=============================================
- Hits          89611     1344    -88267     
+ Misses       422064    35318   -386746     
+ Partials      10057      160     -9897     
Flag Coverage Δ
uitests 3.64% <ø> (-0.11%) ⬇️
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan
Copy link

UI build: ✔️
Live QA URL: https://qa.cloudstack.cloud/simulator/pr/11359 (QA-JID-710)

@AndrewHaZG AndrewHaZG closed this Jul 31, 2025
@AndrewHaZG AndrewHaZG force-pushed the fix-cookie-logout-issue-11078 branch from 5c44461 to 6589235 Compare July 31, 2025 11:37
@DaanHoogland
Copy link
Contributor

@AndrewHaZG , any reason you closed your new commit?

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: Cannot log out / Invalid session cookies causes login page to flood API calls

4 participants