From fb1bbf6fcffda30586b5687e8e7e316daf74cc8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20=C5=A0imi=C4=87?= Date: Mon, 16 Apr 2012 02:08:27 +0300 Subject: [PATCH] formatting fixes --- README.rdoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rdoc b/README.rdoc index 4c44cd1..3930e58 100644 --- a/README.rdoc +++ b/README.rdoc @@ -35,18 +35,18 @@ AuthHMAC.sign! takes a HTTP request object, an access id and a secret key and si * The access_id is used to identify the secret key that was used to sign the request. Think of it as like a user name, it allows you to hand out different keys to different clients and authenticate each of them individually. The access_id is sent in the clear so you should avoid making it an important string. * The secret key is the shared secret between the client and the server. You should make this sufficiently random so that is can't be guessed or exposed to dictionary attacks. The follow code will give you a pretty good secret key: - random = File.read('/dev/random', 512) - secret_key = [Digest::SHA2.new(512).digest(random)].pack('m') + random = File.read('/dev/random', 512) + secret_key = [Digest::SHA2.new(512).digest(random)].pack('m') On the server side you can then authenticate these requests using the AuthHMAC.authenticated? method. This takes the same arguments as the sign! method but returns true if the request has been signed with the access id and secret or false if it hasn't. If you have more than one set of credentials you might find it useful to create an instance of the AuthHMAC class, passing your credentials as a Hash of access id => secret keys, like so: - @authhmac = AuthHMAC.new('access_id1' => 'secret1', 'access_id2' => 'secret2') + @authhmac = AuthHMAC.new('access_id1' => 'secret1', 'access_id2' => 'secret2') You can then use the instance methods of the @authhmac object to sign and authenticate requests, for example: - @authhmac.sign!(request, "access_id1") + @authhmac.sign!(request, "access_id1") will sign +request+ with "access_id1" and it's corresponding secret key. Similarly authentication is done like so: