There are three options:
- Header
- URL
- Body
I haven't done too much work with authentication but am building an API that will need it. What I have done previously is parse the API key (e.g sha-256) in the body of a post request.
But I have just realised that you can't do this with GET requests, right? So I need to find the most secure way of authenticating each API request.
I was thinking, would it be more secure to pass the user's authenticationkey (which is stored in the users database table) as well as an oAuth key with each request? This way any hacker would need two keys to get into the system?
How should I go about this?
Example:
To authenticate every request, would I have the router check each request for an API key?
Sort of like this:
app.all('/api/v1/*', [require('./middlewares/validateRequestAPIKEY')]);