devise_authenticator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/autotest/discover.rb +1 -0
- data/devise_authenticator.gemspec +24 -0
- data/lib/devise_authenticator/version.rb +3 -0
- data/lib/devise_authenticator.rb +17 -0
- data/spec/devise_authenticator_spec.rb +13 -0
- data/spec/spec_helper.rb +3 -0
- metadata +104 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Autotest.add_discovery{"rspec2"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "devise_authenticator/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "devise_authenticator"
|
7
|
+
s.version = DeviseAuthenticator::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Douglas Campos"]
|
10
|
+
s.email = ["qmx@qmx.me"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{mimics devise's default hashing strategy}
|
13
|
+
s.description = %q{helps to authenticate against a default devise database}
|
14
|
+
|
15
|
+
s.rubyforge_project = "devise_authenticator"
|
16
|
+
|
17
|
+
s.add_development_dependency "bcrypt-ruby"
|
18
|
+
s.add_development_dependency "rspec"
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bcrypt'
|
2
|
+
module DeviseAuthenticator
|
3
|
+
class Config
|
4
|
+
attr_accessor :pepper
|
5
|
+
end
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@@config = yield DeviseAuthenticator::Config.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def valid_password?(password, encrypted_password)
|
12
|
+
bc = BCrypt::Password.new(encrypted_password)
|
13
|
+
hashed_password = BCrypt::Engine.hash_secret("#{password}#{@@config.pepper}", bc.salt)
|
14
|
+
hashed_password == encrypted_password
|
15
|
+
end
|
16
|
+
module_function :setup, :valid_password?
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DeviseAuthenticator do
|
4
|
+
let(:password){"w00tw00t"}
|
5
|
+
let(:encrypted_password){"$2a$10$EYBGqTSJs6GKH0T3Rw7zrefN1kBMOfwD0v9GOccq1BnIVDEcQ4aU."}
|
6
|
+
it "should generate devise hash for a given password" do
|
7
|
+
DeviseAuthenticator.setup do |config|
|
8
|
+
config.pepper = "42888246834065a0e7b0c1ca33997e3ed1aede62abe8062328acf4b8e64ca979d8d22ccf54b1c5bca19c6098d0050b500fe77b9c5aeb4f4a6a182f415eb439db"
|
9
|
+
config
|
10
|
+
end
|
11
|
+
DeviseAuthenticator.valid_password?(password, encrypted_password).should == true
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devise_authenticator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Douglas Campos
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-27 00:00:00 -03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bcrypt-ruby
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
description: helps to authenticate against a default devise database
|
50
|
+
email:
|
51
|
+
- qmx@qmx.me
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- Gemfile
|
61
|
+
- Rakefile
|
62
|
+
- autotest/discover.rb
|
63
|
+
- devise_authenticator.gemspec
|
64
|
+
- lib/devise_authenticator.rb
|
65
|
+
- lib/devise_authenticator/version.rb
|
66
|
+
- spec/devise_authenticator_spec.rb
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: ""
|
70
|
+
licenses: []
|
71
|
+
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
hash: 3
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
requirements: []
|
96
|
+
|
97
|
+
rubyforge_project: devise_authenticator
|
98
|
+
rubygems_version: 1.5.2
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: mimics devise's default hashing strategy
|
102
|
+
test_files:
|
103
|
+
- spec/devise_authenticator_spec.rb
|
104
|
+
- spec/spec_helper.rb
|