Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the ui_lang & accepts-cookies preference cookies Secure #7541

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

brionmario
Copy link
Member

@brionmario brionmario commented Feb 7, 2025

Purpose

This pull request includes several changes aimed at enhancing the security of cookies by making them secure. The changes span across multiple files and involve adding the Secure attribute to cookies and updating related functions to support additional options for cookies.

Security Enhancements:

Related Issues

Related PRs

  • N/A

Checklist

  • e2e cypress tests locally verified. (for internal contributers)
  • Manual test round performed and verified.
  • UX/UI review done on the final implementation.
  • Documentation provided. (Add links if there are any)
  • Relevant backend changes deployed and verified
  • Unit tests provided. (Add links if there are any)
  • Integration tests provided. (Add links if there are any)

Security checks

@brionmario brionmario changed the title Make the accepts-cookies cookie Secure Make the ui_lang & accepts-cookies preference cookies Secure Feb 7, 2025
var expires = "";
var domain = ";domain=" + URLUtils.getDomain(window.location.href);

if (days) {
const date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
var date = new Date();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need to avoid const since es6 is widely supported?

https://caniuse.com/?search=es6

}

/**
* Handles language change by setting the `ui_locale` cookie.
*/
function setUILocaleCookie(language) {
var EXPIRY_DAYS = 30;
setCookie('ui_lang', language, EXPIRY_DAYS);
setCookie('ui_lang', language, EXPIRY_DAYS, { secure: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 41.85%. Comparing base (07703d3) to head (b53a2f5).
Report is 45 commits behind head on master.

Files with missing lines Patch % Lines
modules/core/src/utils/storage-utils.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7541      +/-   ##
==========================================
+ Coverage   41.77%   41.85%   +0.07%     
==========================================
  Files          42       42              
  Lines         936      939       +3     
  Branches      235      238       +3     
==========================================
+ Hits          391      393       +2     
- Misses        501      502       +1     
  Partials       44       44              
Flag Coverage Δ
@wso2is/core 41.85% <80.00%> (+0.07%) ⬆️

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

Files with missing lines Coverage Δ
modules/core/src/utils/storage-utils.ts 60.00% <80.00%> (+0.47%) ⬆️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants