Previously, I thought that the PHPcURL simulation request also had cross-origin restrictions. If you have any questions about the sensitive data that requires permission access when designing an interface (for example, personal data that needs to be viewed after logon ). I will perform token detection. However, other common interfaces can be obtained directly, but only cross...
Previously I thoughtPHP cURL
Simulated requests also have cross-origin restrictions.
Question
When designing an interface, you must have the permission to access sensitive data (for example, personal data that needs to be viewed after logon ). I will dotoken
Detected.
However, other common interfaces can be directly obtained by adding a cross-origin header to prevent cross-origin calls. HoweverPHP cURL
Yes. Later I readeechen
. As follows:
The same-origin policy prevents cross-origin from being a security mechanism in browsers. PHP's cURL can be seen as a browser (client) under the command line without any restrictions, just as you use file_get_contents to download things on the Internet as you wish, and the source.
Does the design seem unreasonable?JS Ajax
Cross-origin restrictions,PHP cURL
In this form, there is no cross-origin restriction. Why didn't I set cross-origin restrictions?PHP cURL
What is the form of cross-origin restriction?
How can we prevent cross-origin calls in this form?
Solution
I have read this before when I wanted to be a NetEase cloud client.NetEase Cloud Music
ThroughCSRF_TOKEN
Prevents cross-origin calls.
PS: It seems that this solution can be obtained through web crawling.CSRF_TOKEN
And then perform cross-origin calls?
In addition, is there any solution to solve this problem?
Thank you for your answers!
============== 10-27 ==========================
Sorry, I got it wrong... I thought it wasPHP cURL
What special processing is done. Thank you.South Bird
In fact, it is equivalent to directly accessing the specifiedURL
, Naturally, there will be no cross-origin issues...
What if I want my interface to be inaccessible to the outside world?
On the intranet
You do not need to set anything for this.
Internet
SetCSRF_TOKEN
But I checked some information about CSRF_TOKEN.CSRF_TOKEN
Mainly to preventCross-Site Request Forgery
Is not used to do this... prevent carrying your authorization informationcookie:SESSIONID
Attack.
CheckREFER
.
What else can I do?
I plan to useJWT
GenerateToken
, Each time, the request must carryToken
(Including user information and permission control ).
Sorry. Thank you too.Gforce
.
Reply content:
Previously I thoughtPHP cURL
Simulated requests also have cross-origin restrictions.
Question
When designing an interface, you must have the permission to access sensitive data (for example, personal data that needs to be viewed after logon ). I will dotoken
Detected.
However, other common interfaces can be directly obtained by adding a cross-origin header to prevent cross-origin calls. HoweverPHP cURL
Yes. Later I readeechen
. As follows:
The same-origin policy prevents cross-origin from being a security mechanism in browsers. PHP's cURL can be seen as a browser (client) under the command line without any restrictions, just as you use file_get_contents to download things on the Internet as you wish, and the source.
Does the design seem unreasonable?JS Ajax
Cross-origin restrictions,PHP cURL
In this form, there is no cross-origin restriction. Why didn't I set cross-origin restrictions?PHP cURL
What is the form of cross-origin restriction?
How can we prevent cross-origin calls in this form?
Solution
I have read this before when I wanted to be a NetEase cloud client.NetEase Cloud Music
ThroughCSRF_TOKEN
Prevents cross-origin calls.
PS: It seems that this solution can be obtained through web crawling.CSRF_TOKEN
And then perform cross-origin calls?
In addition, is there any solution to solve this problem?
Thank you for your answers!
============== 10-27 ==========================
Sorry, I got it wrong... I thought it wasPHP cURL
What special processing is done. Thank you.South Bird
In fact, it is equivalent to directly accessing the specifiedURL
, Naturally, there will be no cross-origin issues...
What if I want my interface to be inaccessible to the outside world?
On the intranet
You do not need to set anything for this.
Internet
SetCSRF_TOKEN
But I checked some information about CSRF_TOKEN.CSRF_TOKEN
Mainly to preventCross-Site Request Forgery
Is not used to do this... prevent carrying your authorization informationcookie:SESSIONID
Attack.
CheckREFER
.
What else can I do?
I plan to useJWT
GenerateToken
, Each time, the request must carryToken
(Including user information and permission control ).
Sorry. Thank you too.Gforce
.
Php curl is equivalent to directly opening a website in your browser, so it is not a cross-origin.
You can perform an Interface Verification, for example, using JWT