rails_validations_hmac 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -7
- data/lib/rails_validations_hmac/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Usage
|
|
13
13
|
|
14
14
|
class ApiUser < ActiveRecord::Base
|
15
15
|
has_many :posts
|
16
|
-
validates :
|
16
|
+
validates :secret_key, presence: true
|
17
17
|
validates :secret_algorithm, presence: true
|
18
18
|
end
|
19
19
|
|
@@ -25,21 +25,21 @@ class Post < ActiveRecord::Base
|
|
25
25
|
|
26
26
|
# these have same meaning (supports Lambdas and Symbols evaluating):
|
27
27
|
validate :hmac, precence: true, hmac: {
|
28
|
-
|
29
|
-
|
28
|
+
key: lambda { api_user.secret_key },
|
29
|
+
data: lambda { API_FIELDS.collect{|m| send(m) }.join },
|
30
30
|
algorithm: lambda { api_user.secret_algorithm }
|
31
31
|
}
|
32
32
|
|
33
33
|
validates :hmac, presence: true, hmac: {
|
34
|
-
|
35
|
-
|
34
|
+
key: :'api_user.secret_key',
|
35
|
+
data: API_FIELDS,
|
36
36
|
algorithm: :'api_user.secret_algorithm'
|
37
37
|
}
|
38
38
|
|
39
39
|
# these are not evaluated (presumed that static value is written)
|
40
40
|
validates :hmac, presence: true, hmac: {
|
41
|
-
|
42
|
-
|
41
|
+
key: 'all_the_time_same',
|
42
|
+
data: 'why you would like to have a static value here?',
|
43
43
|
algorithm: 'md5' # by default its sha1
|
44
44
|
}
|
45
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_validations_hmac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
212
|
version: '0'
|
213
213
|
segments:
|
214
214
|
- 0
|
215
|
-
hash:
|
215
|
+
hash: 1495700232791925941
|
216
216
|
requirements: []
|
217
217
|
rubyforge_project:
|
218
218
|
rubygems_version: 1.8.24
|