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

DESENG-484: Adding max age for cors #2377

Merged
merged 8 commits into from
Feb 9, 2024

Conversation

VineetBala-AOT
Copy link
Collaborator

Issue #: https://apps.itsm.gov.bc.ca/jira/browse/DESENG-484

Description of changes:
- Introduces a new configuration variable to specify the maximum age for Cross-Origin Resource Sharing (CORS)
- Modified the CORS preflight method to utilize this newly introduced variable.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the met-public license (Apache 2.0).

@VineetBala-AOT VineetBala-AOT marked this pull request as ready for review February 8, 2024 20:38
Copy link

sonarqubecloud bot commented Feb 8, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link
Collaborator

@Baelx Baelx left a comment

Choose a reason for hiding this comment

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

Nice work ! Looks like we may be limited in truly reducing OPTIONS calls but the max age value will hopefully help a lot!

Could you please review my question before we proceed with his PR?

# This value is used to indicate how long the results of a preflight request (OPTIONS) can be cached
# by the client, reducing the frequency of preflight requests for the specified HTTP methods.
# Adjust this value based on security considerations.
CORS_MAX_AGE = os.getenv('CORS_MAX_AGE', None) # Default: 0 seconds
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that you did this with an environment variable! A couple things:

  • Could we make sure to set this in Openshift before we close the ticket? Looks like 2 hours is the maximum value for modern chromium browsers (Firefox is 72 hrs). Either this or we could set the default to be 2 hours.
  • Our server is CORS-aware and checking for CORS origins so what are the security considerations here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I will set it in Openshift before closing the ticket.

For enhanced security considerations, configuring Access-Control-Max-Age as an environment variable provides the flexibility to adjust its duration or even eliminate it entirely in response to security concerns. Online recommendations suggest maintaining a shorter duration for Access-Control-Max-Age to mitigate potential risks.

@VineetBala-AOT VineetBala-AOT requested a review from Baelx February 8, 2024 23:27
@VineetBala-AOT VineetBala-AOT merged commit 9be6576 into bcgov:feature/deseng-484 Feb 9, 2024
1 check passed
VineetBala-AOT added a commit that referenced this pull request Feb 12, 2024
* DESENG-484: Adding max age for cors (#2377)
NatSquared pushed a commit that referenced this pull request Feb 12, 2024
* DESENG-484: Adding max age for cors (#2377)
ratheesh-aot pushed a commit to ratheesh-aot/met-public that referenced this pull request Feb 16, 2024
* DESENG-484: Adding max age for cors (bcgov#2377)
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