authi 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/authi.rb +16 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ebecea59ce64d2f65ac72affea7b2ce1ccb443a
|
4
|
+
data.tar.gz: bb120684e24f4263963a1d92aa1e6efee5b07f97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3413573cb69ae633cba8fefb86b16cef459b477a7e64f5a3baf91768db0783f2cddc293b5433a3bb429d1132fb07a6b6ff1bfb5792bf8459b4307ef101a51b2e
|
7
|
+
data.tar.gz: 231b6c27c3e5ef2ad5c34dd9a7a1affbb6c96a5eb8f98c8106a21f22cb9f8853337b6d90c5009823cf189c620ee65a03a38b0813d75aeced539e59ba86ab36a6
|
data/lib/authi.rb
CHANGED
@@ -2,24 +2,24 @@ require 'openssl'
|
|
2
2
|
require 'base64'
|
3
3
|
require 'securerandom'
|
4
4
|
# Api Authentication Module
|
5
|
-
#
|
6
|
-
#
|
5
|
+
# =========================
|
6
|
+
# <b>How it works</b>
|
7
|
+
# ============
|
8
|
+
# <i>Client Side</i>
|
7
9
|
# ===========
|
8
10
|
# A string is first created using your HTTP payload containing all parameters and a preshared key.
|
9
11
|
# This string is then used to create the signature which is a Base64 encoded SHA1 HMAC, using the clients private secret key.
|
10
|
-
# This signature is then can be added to Authorization HTTP header
|
11
|
-
# Authorization = Authy.generate_signed_header(params)
|
12
|
-
# Now add this to to your header
|
13
|
-
# header["Authorization"] = Authorization
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# API validation
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# ---------------------------------
|
22
|
-
# secret_key = Authy.generate_secret_key
|
12
|
+
# This signature is then can be added to Authorization HTTP header
|
13
|
+
# <code>Authorization = Authy.generate_signed_header(params)</code>
|
14
|
+
# Now add this to to your header
|
15
|
+
# <code>header["Authorization"] = Authorization</code>
|
16
|
+
#
|
17
|
+
# secret_key generated from the server side can be kept inside the a environment variable with name "shared_key" along with "service_name" as your service name
|
18
|
+
#
|
19
|
+
# <i>Server Side API validation</i>
|
20
|
+
# <code>is_valid = Authy.validate_api(params, request.headers)<code>
|
21
|
+
# Generating secret key for clients
|
22
|
+
# <code>secret_key = Authy.generate_secret_key<code>
|
23
23
|
module Authy
|
24
24
|
# Create a signed hash using input parameter
|
25
25
|
#
|
@@ -64,7 +64,7 @@ module Authy
|
|
64
64
|
[fully_qualified_keys.join(','), map]
|
65
65
|
end
|
66
66
|
|
67
|
-
# Utility method to build
|
67
|
+
# Utility method to build query from deep lookup table and parameters
|
68
68
|
def self.build_query(processed_data, deep_lookup_table) # :nodoc:
|
69
69
|
query = []
|
70
70
|
processed_data.split(',').each { |data| query << data + '=' + deep_lookup_table[data].to_s }
|