rails_validations_hmac 0.0.1 → 0.0.2

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.
data/README.md CHANGED
@@ -1,20 +1,14 @@
1
1
  Intro
2
2
  =====
3
-
4
3
  Runs fast using OpenSSL::HMAC.
5
4
 
6
-
7
5
  Supports
8
6
  --------
9
-
10
- * ActiveRecord
11
- * On creating Issue and requesting, for other ORMs also
12
-
13
-
7
+ * ORMs and DOMs that use ActiveModel [hmac_validator.rb (30 sloc)](https://github.com/tione/rails_validations_hmac/blob/master/lib/rails_validations_hmac/support/active_model/validations/hmac_validator.rb)
8
+ * If support for something is missing, add an issue and the support will be added
14
9
 
15
10
  Usage
16
11
  =====
17
-
18
12
  ```ruby
19
13
 
20
14
  class ApiUser < ActiveRecord::Base
@@ -25,15 +19,11 @@ end
25
19
 
26
20
  class Post < ActiveRecord::Base
27
21
  API_FIELDS = [:title, :body].sort # keep them in alphabetic order!
28
-
29
22
  attr_accessible :api_user_id, :hmac
30
23
  attr_accessible *MESSAGE_FIELDS
31
-
32
24
  belongs_to :api_user
33
25
 
34
-
35
26
  # these have same meaning (supports Lambdas and Symbols evaluating):
36
-
37
27
  validate :hmac, precence: true, hmac: {
38
28
  secret: lambda { api_user.secret },
39
29
  content: lambda { API_FIELDS.collect{|m| send(m) }.join },
@@ -46,22 +36,17 @@ class Post < ActiveRecord::Base
46
36
  algorithm: :'api_user.secret_algorithm'
47
37
  }
48
38
 
49
-
50
39
  # these are not evaluated (presumed that static value is written)
51
-
52
40
  validates :hmac, presence: true, hmac: {
53
41
  secret: 'all_the_time_same',
54
42
  content: 'why you would like to have a static value here?',
55
43
  algorithm: 'md5' # by default its sha1
56
44
  }
57
-
58
45
  end
59
46
  ```
60
47
 
61
-
62
48
  Valid options
63
49
  -------------
64
-
65
50
  * key (required) - secret preshared key
66
51
  * data (required) - data to be controlled with HMAC
67
52
  * algorithm (optional) - by default 'sha1', 'md5', 'sha256', 'sha384', 'sha512' also supported
@@ -70,7 +55,6 @@ Valid options
70
55
 
71
56
  Read more
72
57
  =========
73
-
74
58
  * http://en.wikipedia.org/wiki/Hash-based_message_authentication_code
75
59
  * http://blog.nathanielbibler.com/post/63031273/openssl-hmac-vs-ruby-hmac-benchmarks
76
60
  * http://ruby-doc.org/stdlib-1.9.3/libdoc/openssl/rdoc/OpenSSL/HMAC.html
@@ -1117,3 +1117,20 @@ Connecting to database specified by database.yml
1117
1117
   (0.1ms) rollback transaction
1118
1118
   (0.1ms) begin transaction
1119
1119
   (0.1ms) rollback transaction
1120
+ Connecting to database specified by database.yml
1121
+  (8.2ms) begin transaction
1122
+  (0.1ms) rollback transaction
1123
+  (0.1ms) begin transaction
1124
+  (0.1ms) rollback transaction
1125
+  (0.1ms) begin transaction
1126
+  (0.1ms) rollback transaction
1127
+  (0.1ms) begin transaction
1128
+  (0.1ms) rollback transaction
1129
+  (0.2ms) begin transaction
1130
+  (0.1ms) rollback transaction
1131
+  (0.1ms) begin transaction
1132
+  (0.1ms) rollback transaction
1133
+  (0.1ms) begin transaction
1134
+  (0.1ms) rollback transaction
1135
+  (0.1ms) begin transaction
1136
+  (0.1ms) rollback transaction
@@ -58,7 +58,7 @@ describe ActiveModel::Validations::HmacValidator do
58
58
 
59
59
  describe "#validate_each" do
60
60
  context "valid hmac" do
61
- it "does not add error" do
61
+ it "does not add an error" do
62
62
  class Post
63
63
  validates :hmac, hmac: {key: :'api_user.secret', data: [:body, :title]}
64
64
  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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-27 00:00:00.000000000 Z
12
+ date: 2012-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: mongoid
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: rspec-rails
64
80
  requirement: !ruby/object:Gem::Requirement
@@ -174,7 +190,7 @@ files:
174
190
  - spec/dummy/Rakefile
175
191
  - spec/dummy/README.rdoc
176
192
  - spec/dummy/script/rails
177
- - spec/lib/active_model/validations/hmac_validator_spec.rb
193
+ - spec/lib/support/active_model/validations/hmac_validator_spec.rb
178
194
  - spec/spec_helper.rb
179
195
  homepage: https://github.com/tione/rails_validations_hmac
180
196
  licenses: []
@@ -196,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
212
  version: '0'
197
213
  segments:
198
214
  - 0
199
- hash: 1337768765338415342
215
+ hash: -721065036959082116
200
216
  requirements: []
201
217
  rubyforge_project:
202
218
  rubygems_version: 1.8.24
@@ -242,5 +258,5 @@ test_files:
242
258
  - spec/dummy/Rakefile
243
259
  - spec/dummy/README.rdoc
244
260
  - spec/dummy/script/rails
245
- - spec/lib/active_model/validations/hmac_validator_spec.rb
261
+ - spec/lib/support/active_model/validations/hmac_validator_spec.rb
246
262
  - spec/spec_helper.rb