I am trying to implement a web service and need some (very) simple Authenticate to restrict access to the service.
I found out about HMAC and I think I understand how to implement it. But I have a couple of questions in mind.
Let's say I have this HTML Form on the consumer side. When making a GET/POST request to my server.
- Is is enough to create a hash of:
public_key
using thesecret_key
? - OR, do I need to create a hash of the entire
POST
variables/array?
I'm thinking it would be enough to send the hash of the public_key
only but just wanted to make sure and ask you guys.
I am planning to do this:
- Create a hash of the
public_key
- Put the hash in a hidden field or in the URL as a param together with the public_key (or client_id) and other POST/GET variables.
- Receive on my server and verify the hash against the database by recreating the hash of the
public_key
using thesecret_key
. - If the hash matches, I accept the POST/GET requests.
Your thoughts?
Clarification: public_key
is like the client unique id
where I can use to identify what secret key
to use to generate the hash on the server.