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

fix: set access-control-allow-credentials=true for auth.pl #7022

Merged
merged 4 commits into from
Jul 13, 2022

Conversation

stephanegigandet
Copy link
Contributor

Fix for #6462

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

LGTM - proposed an improvement, but not mandatory

cgi/auth.pl Outdated
# such has hunger.openfoodfacts.org that send a query to world.openfoodfacts.org/cgi/auth.pl
# can read the resulting response.

print header(-Access_Control_Allow_Credentials => "true");
Copy link
Member

Choose a reason for hiding this comment

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

As we are sending the header from here, couldn't we first check for referer and limit this to:

defined env["HTTP_REFERER"] and env["HTTP_REFERER"] =~ /^(?:https?://)\w+$main_domain/

assuming $main_domain contains openfoodfacts.org/net/localhost

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I added a change like this. The browser will send an Origin header.

@alexgarel
Copy link
Member

ok, I imagine you will test before merging ?

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@alexgarel
Copy link
Member

@stephanegigandet is this ready to merge ?

@stephanegigandet
Copy link
Contributor Author

@alexgarel I was waiting for @alexfauquette to confirm it works as expected: #6462
In practice I have already deployed this in production, so I guess we can merge, and open a new PR if needed.

@alexgarel alexgarel merged commit 423df0f into main Jul 13, 2022
@alexgarel alexgarel deleted the allow-credentials branch July 13, 2022 12:56
LandonPattison pushed a commit that referenced this pull request Jul 24, 2022
* fix access-control-allow-origin header
* allow only our subdomains
* Origin header does not contain the path

Co-authored-by: off <off@openfoodfacts.org>
LandonPattison pushed a commit that referenced this pull request Jul 25, 2022
* fix access-control-allow-origin header
* allow only our subdomains
* Origin header does not contain the path

Co-authored-by: off <off@openfoodfacts.org>
LandonPattison pushed a commit that referenced this pull request Jul 25, 2022
* fix access-control-allow-origin header
* allow only our subdomains
* Origin header does not contain the path

Co-authored-by: off <off@openfoodfacts.org>
LandonPattison pushed a commit that referenced this pull request Jul 25, 2022
* fix access-control-allow-origin header
* allow only our subdomains
* Origin header does not contain the path

Co-authored-by: off <off@openfoodfacts.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants