Excuse me @MarkAmery and Eugene, but this is not true.
Your js + html (client) application running in the browser can be configured to exclude unauthorized direct API calls, as shown below:
- First step: configure the API for authentication. The client must first authenticate through the server (or some other security server), for example, ask the person to provide the correct password.
Prior to authentication, API calls are not accepted.
During authentication, a token is returned.
After authentication, only API calls with token authentication will be accepted.
Of course, at this stage only authorized users who have a password can access the API, although if they program debugging the application, they can access it directly for testing purposes.
- Second step: Now configure an additional security API, which should be called within a short period of time after the js + html client application was originally requested from the server. This “callback” tells the server that the client was loaded successfully. Restrict REST API calls to work only if the client has been requested recently and successfully.
Now, in order to use your API, they must first download the client and actually run it in the browser. Only after successfully receiving the callback and then entering the user for a short period of time, the API will receive calls.
This way, you don’t have to worry about being an unauthorized user without credentials.
(Question title: “How can I protect REST API calls,” and from most of what you say, this is your main problem, not the literal question of how you call your API, but rather WH WHOM, right?)
pashute Nov 12 '15 at 2:58 2015-11-12 14:58
source share