handshakejs 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1,5 @@
1
1
  script: "bundle exec rspec"
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - "2.0.0"
data/README.md CHANGED
@@ -2,9 +2,12 @@
2
2
 
3
3
  Makes interacting with handshakejs easier in ruby.
4
4
 
5
+ [![Build Status](https://travis-ci.org/handshakejs/handshakejs-ruby.svg?branch=master)](https://travis-ci.org/handshakejs/handshakejs-ruby)
6
+ [![Gem Version](https://badge.fury.io/rb/handshakejs.svg)](http://badge.fury.io/rb/handshakejs)
7
+
5
8
  ```ruby
6
9
  Handshakejs.salt = "your_long_secret_salt"
7
- Handshakejs.valid?({email: email, hash: hash})
10
+ Handshakejs.validate({:email => email, :hash => hash})
8
11
  ```
9
12
 
10
13
  ## Running Specs
@@ -19,7 +22,7 @@ You first need to request access from [scottmotte](http://github.com/scottmotte)
19
22
 
20
23
  ```
21
24
  gem build handshakejs.gemspec
22
- gem push handshakejs-0.0.1.gem
25
+ gem push handshakejs-0.0.2.gem
23
26
  ```
24
27
 
25
28
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.summary = %q{Rubygem for Handshakejs session check.}
13
13
  gem.homepage = "http://github.com/scottmotte/handshakejs-ruby"
14
14
 
15
- gem.add_dependency "pbkdf2", "0.1.0"
15
+ gem.add_dependency "armor", "0.0.3"
16
16
 
17
17
  gem.add_development_dependency "foreman"
18
18
  gem.add_development_dependency "pry"
@@ -1,4 +1,4 @@
1
- require "pbkdf2"
1
+ require "armor"
2
2
  require "handshakejs/version"
3
3
 
4
4
  module Handshakejs
@@ -37,20 +37,26 @@ module Handshakejs
37
37
  16
38
38
  end
39
39
 
40
- def validate(params={})
41
- pbkdf2 = PBKDF2.new do |p|
42
- p.password = params[:email]
43
- p.salt = Handshakejs.salt
44
- p.iterations = Handshakejs.iterations
45
- p.key_length = Handshakejs.key_length
46
- p.hash_function = "sha1"
47
- end
40
+ def hash_function=(hash_function)
41
+ @hash_function = hash_function
42
+
43
+ @hash_function
44
+ end
45
+
46
+ def hash_function
47
+ return @hash_function if @hash_function
48
+ "sha1"
49
+ end
50
+
51
+ def digest
52
+ Armor::Digest.new(hash_function)
53
+ end
48
54
 
49
- puts pbkdf2.hex_string
55
+ def validate(params={})
56
+ password = params[:email]
50
57
 
51
- params[:hash] == pbkdf2.hex_string
58
+ result = Armor.hex(Armor.pbkdf2(digest, password, salt, Integer(iterations), key_length))
52
59
 
53
- #pbkdf2 = PBKDF2.new(:password=>params[:email], :salt=>Hanshakejs.salt, :iterations=>1000, :key_length => 16, :hash_function => "sha1")
54
- #session[:user] = params[:email] if pbkdf2.hex_string == params[:hash]
60
+ params[:hash] == result
55
61
  end
56
62
  end
@@ -1,3 +1,3 @@
1
1
  module Handshakejs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -7,9 +7,10 @@ describe Handshakejs do
7
7
  end
8
8
 
9
9
  it { Handshakejs.salt.should eq "salt_required" }
10
- it { Handshakejs::VERSION.should eq "0.0.1" }
10
+ it { Handshakejs::VERSION.should eq "0.0.2" }
11
11
  it { Handshakejs.iterations.should eq 1000 }
12
12
  it { Handshakejs.key_length.should eq 16 }
13
+ it { Handshakejs.hash_function.should eq "sha1" }
13
14
  end
14
15
 
15
16
  describe "setting values" do
@@ -32,28 +33,28 @@ describe Handshakejs do
32
33
  end
33
34
 
34
35
  it "is valid against against a correct email, hash combination" do
35
- result = Handshakejs.validate({email: email, hash: hash})
36
+ result = Handshakejs.validate({:email => email, :hash => hash})
36
37
 
37
38
  result.should be_true
38
39
  end
39
40
 
40
41
  it "is invalid against against an incorrect email" do
41
42
  email = "different@email.com"
42
- result = Handshakejs.validate({email: email, hash: hash})
43
+ result = Handshakejs.validate({:email => email, :hash => hash})
43
44
 
44
45
  result.should be_false
45
46
  end
46
47
 
47
48
  it "is invalid against against an incorrect hash" do
48
49
  hash = "differenthash"
49
- result = Handshakejs.validate({email: email, hash: hash})
50
+ result = Handshakejs.validate({:email => email, :hash => hash})
50
51
 
51
52
  result.should be_false
52
53
  end
53
54
 
54
55
  it "is invalid against against a different salt" do
55
56
  Handshakejs.salt = "different"
56
- result = Handshakejs.validate({email: email, hash: hash})
57
+ result = Handshakejs.validate({:email => email, :hash => hash})
57
58
 
58
59
  result.should be_false
59
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handshakejs
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,16 +9,16 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-16 00:00:00.000000000 Z
12
+ date: 2014-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: pbkdf2
15
+ name: armor
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.1.0
21
+ version: 0.0.3
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.1.0
29
+ version: 0.0.3
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: foreman
32
32
  requirement: !ruby/object:Gem::Requirement