yubikey_database_authenticatable 0.3.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,9 +6,11 @@ This extension requires the used to already have a valid account and password an
6
6
 
7
7
  ## Installation
8
8
 
9
- This plugin requires Rails 3.0.x and 3.1.x and Devise 1.3.4+. Additionally the Yubikey Ruby library found here is required.
9
+ This plugin requires Rails 3.0.x, 3.1.x and 3.2.x and Devise 2.2.3+. Additionally the Yubikey Ruby library found here is required.
10
10
 
11
11
  <https://github.com/titanous/yubikey>
12
+
13
+ The latest git version has a fix for a MITM attack element when communicating with the Yubico servers, this doesn't appear to be reflected in the published gem.
12
14
 
13
15
  The gem for the Yubikey library will need to be added to your Gemfile. To install the plugin add this plugin to your Gemfile.
14
16
 
@@ -18,10 +20,17 @@ The gem for the Yubikey library will need to be added to your Gemfile. To instal
18
20
 
19
21
  Once the plugin is installed, all you need to do is setup the user model which includes a small addition to the model itself and to the schema.
20
22
 
23
+ In order to communicate with the Yubikey authentication services the API key will need to be provided, this should be included into the Devise config, set yubikey_api_key and yubikey_api_id in the Devise configuration file (in config/initializers/devise.rb).
24
+
25
+ Get a key here: <https://upgrade.yubico.com/getapikey/>
26
+
27
+ config.yubikey_api_key = "" # => API Key must be set to validate one time passwords
28
+ config.yubikey_api_id = "" # => API ID must be set to validate one time passwords
29
+
21
30
  The following needs to be added to the User module.
22
31
 
23
- add_column :users, :useyubikey, :boolean
24
- add_column :users, :registeredyubikey, :string
32
+ add_column :users, :use_yubikey, :boolean
33
+ add_column :users, :registered_yubikey, :string
25
34
 
26
35
  then finally add to the model:
27
36
 
@@ -30,12 +39,12 @@ then finally add to the model:
30
39
  devise :yubikey_database_authenticatable, :trackable, :timeoutable
31
40
 
32
41
  # Setup accessible (or protected) attributes for your model
33
- attr_accessible :useyubikey, :registeredyubikey, :yubiotp
42
+ attr_accessible :use_yubikey, :registered_yubikey, :yubiotp
34
43
 
35
44
  attr_accessor :yubiotp
36
45
 
37
- def registeredyubikey=(yubiotp)
38
- write_attribute(:registeredyubikey, yubiotp[0..11])
46
+ def registered_yubikey=(yubiotp)
47
+ write_attribute(:registered_yubikey, yubiotp[0..11])
39
48
  end
40
49
 
41
50
  ...
data/Rakefile CHANGED
@@ -1,22 +1,6 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
- require 'rake/rdoctask'
4
3
 
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "yubiket_database_authenticatable"
9
- gem.summary = %Q{YubiKey OTP Authentication Plugin for Devise}
10
- gem.description = %Q{Extended version of the Devise Database Authentication module to implement YubiKey OTP two factor authentication for registered users}
11
- gem.email = "mort666@virus.org"
12
- gem.homepage = "https://github.com/mort666/yubikey_database_authenticatable"
13
- gem.authors = ["Stephen Kapp"]
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
- end
20
4
 
21
5
  desc 'Default: run unit tests.'
22
6
  task :default => :test
@@ -28,12 +12,3 @@ Rake::TestTask.new(:test) do |t|
28
12
  t.pattern = 'test/**/*_test.rb'
29
13
  t.verbose = true
30
14
  end
31
-
32
- desc 'Generate documentation for the yubikey_database_authenticatable plugin.'
33
- Rake::RDocTask.new(:rdoc) do |rdoc|
34
- rdoc.rdoc_dir = 'rdoc'
35
- rdoc.title = 'YubikeyDatabaseAuthenticatable'
36
- rdoc.options << '--line-numbers' << '--inline-source'
37
- rdoc.rdoc_files.include('README')
38
- rdoc.rdoc_files.include('lib/**/*.rb')
39
- end
@@ -13,7 +13,7 @@ require 'bcrypt'
13
13
 
14
14
  def validate_yubikey(yubiotp)
15
15
  begin
16
- otp = Yubikey::OTP::Verify.new(yubiotp)
16
+ otp = Yubikey::OTP::Verify.new(:otp => yubiotp, :api_id => Devise.yubikey_api_id, :api_key => Devise.yubikey_api_key)
17
17
 
18
18
  if otp.valid?
19
19
  return true
@@ -5,13 +5,14 @@ module Devise
5
5
  class YubikeyDatabaseAuthenticatable < Authenticatable
6
6
  def authenticate!
7
7
  resource = valid_password? && mapping.to.find_for_yubikey_database_authentication(authentication_hash)
8
-
9
- if validate(resource) {resource.valid_password?(password)}
10
- if resource.useyubikey == true
11
- if params[:user][:yubiotp].blank?
12
- fail('Yubikey OTP Required for this user.')
8
+ return fail(:not_found_in_database) unless resource
9
+
10
+ if validate(resource) { resource.valid_password?(password) }
11
+ if resource.use_yubikey == true
12
+ if params[scope][:yubiotp].blank?
13
+ fail('Yubikey OTP Required for this user.')
13
14
  else
14
- if resource.validate_yubikey(params[:user][:yubiotp]) && (resource.registeredyubikey == params[:user][:yubiotp][0..11])
15
+ if resource.validate_yubikey(params[scope][:yubiotp]) && (resource.registered_yubikey == params[scope][:yubiotp][0..11])
15
16
  resource.after_database_authentication
16
17
  success!(resource)
17
18
  else
@@ -29,4 +30,4 @@ module Devise
29
30
  end
30
31
  end
31
32
 
32
- Warden::Strategies.add(:yubikey_database_authenticatable, Devise::Strategies::YubikeyDatabaseAuthenticatable)
33
+ Warden::Strategies.add(:yubikey_database_authenticatable, Devise::Strategies::YubikeyDatabaseAuthenticatable)
@@ -1,3 +1,3 @@
1
1
  module YubikeyDatabaseAuthenticatable
2
- VERSION = "0.3.1".freeze
2
+ VERSION = "0.4.1".freeze
3
3
  end
@@ -8,4 +8,22 @@ require 'devise_yubikey_database_authenticatable/model'
8
8
  require 'devise_yubikey_database_authenticatable/strategy'
9
9
  require 'devise_yubikey_database_authenticatable/routes'
10
10
 
11
+ module Devise
12
+ # Public: The api_key for a yubikey validation
13
+ # Get a key here: https://upgrade.yubico.com/getapikey/
14
+ # Set yubikey_api_key in the Devise configuration file (in config/initializers/devise.rb).
15
+ #
16
+ # config.yubikey_api_key = "" # => Api Key must be set to validate one time passwords
17
+ mattr_accessor :yubikey_api_key
18
+ @@yubikey_api_key = nil
19
+
20
+ # Public: The api_id for a yubikey validation
21
+ # Get a key here: https://upgrade.yubico.com/getapikey/
22
+ # Set yubikey_api_id in the Devise configuration file (in config/initializers/devise.rb).
23
+ #
24
+ # config.yubikey_api_id = "" # => Api ID must be set to validate one time passwords
25
+ mattr_accessor :yubikey_api_id
26
+ @@yubikey_api_id = nil
27
+ end
28
+
11
29
  Devise.add_module(:yubikey_database_authenticatable, :strategy => true, :model => "devise_yubikey_database_authenticatable/model", :route => :session, :controller => :sessions)
@@ -18,6 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_dependency('devise', '~> 1.5.0')
22
- s.add_dependency('yubikey', '~> 1.2.1')
21
+ s.add_dependency('devise', '>= 2.2.3')
22
+ s.add_dependency('yubikey', '~> 1.3.1')
23
+ s.add_development_dependency "active_support"
24
+ s.add_development_dependency "rake"
25
+ s.add_development_dependency "rdoc"
23
26
  end
metadata CHANGED
@@ -1,64 +1,102 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: yubikey_database_authenticatable
3
- version: !ruby/object:Gem::Version
4
- hash: 17
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Stephen Kapp
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-12-04 00:00:00 +00:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-12-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: devise
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.2.3
22
+ type: :runtime
23
23
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.2.3
30
+ - !ruby/object:Gem::Dependency
31
+ name: yubikey
32
+ requirement: !ruby/object:Gem::Requirement
25
33
  none: false
26
- requirements:
34
+ requirements:
27
35
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 1
32
- - 5
33
- - 0
34
- version: 1.5.0
36
+ - !ruby/object:Gem::Version
37
+ version: 1.3.1
35
38
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: yubikey
39
39
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
- requirements:
42
+ requirements:
43
43
  - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 29
46
- segments:
47
- - 1
48
- - 2
49
- - 1
50
- version: 1.2.1
51
- type: :runtime
52
- version_requirements: *id002
44
+ - !ruby/object:Gem::Version
45
+ version: 1.3.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: active_support
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
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'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rdoc
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
53
94
  description: YubiKey OTP Authentication Plugin for Devise
54
95
  email: mort666@virus.org
55
96
  executables: []
56
-
57
97
  extensions: []
58
-
59
98
  extra_rdoc_files: []
60
-
61
- files:
99
+ files:
62
100
  - MIT-LICENSE
63
101
  - README.md
64
102
  - Rakefile
@@ -71,40 +109,30 @@ files:
71
109
  - test/test_helper.rb
72
110
  - test/yubikey_database_authenticatable_test.rb
73
111
  - yubikey_database_authenticatable.gemspec
74
- has_rdoc: true
75
112
  homepage: https://github.com/mort666/yubikey_database_authenticatable
76
113
  licenses: []
77
-
78
114
  post_install_message:
79
115
  rdoc_options: []
80
-
81
- require_paths:
116
+ require_paths:
82
117
  - lib
83
- required_ruby_version: !ruby/object:Gem::Requirement
118
+ required_ruby_version: !ruby/object:Gem::Requirement
84
119
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 0
91
- version: "0"
92
- required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
125
  none: false
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- hash: 3
98
- segments:
99
- - 0
100
- version: "0"
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
101
130
  requirements: []
102
-
103
131
  rubyforge_project:
104
- rubygems_version: 1.6.2
132
+ rubygems_version: 1.8.25
105
133
  signing_key:
106
134
  specification_version: 3
107
135
  summary: YubiKey OTP Authentication Plugin for Devise
108
- test_files:
136
+ test_files:
109
137
  - test/test_helper.rb
110
138
  - test/yubikey_database_authenticatable_test.rb