私の懸念は、誰かがこのURL(https://example.com/retrieveData.php)を盗んだ場合、手動で偽の投稿リクエストを送信し、返されたユーザー情報を盗むことができるということです。
あなたは心配する権利があります。リクエストを承認するリクエストの一部をチェックしない限り、誰でもそのURLにメッセージを送信し、結果を得ることができます。
For example, you could authenticate to check that the request comes from the user and then authorize the request based on the idea that the user should have access to that info.
Alternatively, you can authorize based on something that only a valid requestor would know via a shared secret and rely on the https
part of that URL to prevent shared secrets from becoming public. You give out the secret to trusted partners, and when you generate a web form via PHP (also protected via HTTPS), you include a hidden input containing the shared secret. This is how XSRF protection typically works.
You should think about the following:
- Who should legitimately be able to reach this page? Logged-in users interacting via your phone app, partners who can protect a secret, web API users?
- What credentials do they have for using other parts of your server? Log-in cookies? XSRF tokens? Partner tokens?
- What parts of your app are sent only over secure channels like
https
?
If all of (1) is satisfied by some subset of credentials in (2) and those credentials are only ever sent over (3) then you just need to check (2) in your page. Otherwise, you need to rework your application architecture until that is true.
OWASP has a Guide to Authorization that might come in handy and they also have a number of pages on reviewing authorization code but most of the examples are not PHP specific.