Closed barmstrong closed 14 years ago
Hi,
Thanx for your post. Yes, facebook was the inspiration. Don't know if there is litterature about this mechanism, but I'll try to show you how it works.
The app_key is to identify who (an application) sent the request, so yes it goes through the wire. What never goes through the wire is the app_secret. This shared secret from the server and the client is used to hash the request. In this manner it is not possible for an attacker to compute a different request.
The client (application) sums the request params then add the secret and hashes it. The request is then sent to the server. The server does exactly the same computation, sum the request params (excluding the signature) then add the secret and hashes it and finally compare this to the passed signature. If they match, the request is considered authentic.
Yes, currently an attacker could re-issue the same request, the server will not notice the request comes from an attacker. As you said, it is the reason facebook adds the 'call_id' parameter. I'll make a revision to authlogic_api to take into account the same feature.
Finally, authlogic_api is a good way to authenticate an application. Not a user behind that application. I did this because I needed it in an intranet infrastructure. If you want to authenticate users and application you should have a look to OAuth.
Best Regards,
Pascal.
Thanks for your help! Makes more sense now. I think you're right OAuth is what I need to be looking into. Thanks!
Hi.
Good description on how your app works on server side. Thats what I understood from reading the documentation for the GET method. But I did not see the secret passed in POST requests. How does this library verify authenticity of a POST request? Just calc MD5 sum is not enough, anyone with appid can calc MD5 sum of post data and create a signature.
Please advise.
Thanks
Matt
Hi @mpestritto,
The secret never goes on the wire, it is used as a salt before hashed. For POST and PUT methods, the secret is added at the end of the body and this whole payload is hashed which becomes the signature. (as seen in the build_api_payload
method)
But you are right, the docs doesn't mention where the secret is used for POST, I'll update that.
Best Regards
Thanks for making/posting this!
Is there somewhere I can read up on this approach to authenticating API's? I saw Facebook uses something similar with their apps) but I don't feel like I quite understand it yet. Specifically...
If I understand the server side right...
The app_key never goes across the wire, so when it gets to the server, the server recomputes the signature using it's own app_key and makes sure it matches.
Ok I get this....but
Regarding #2, I'm assuming this is why Facebook passes the microtime (num milliseconds) as an additional param? So maybe that is an additional precaution not used here.
Finally...is this a good way to authenticate BOTH a user and an app? I guess this is what I'm really trying to do. Haven't quite wrapped my head around it though.
Thanks again! Brian