yubikey_database_authenticatable 0.4.1 → 0.5.1
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.
- checksums.yaml +7 -0
- data/.travis.yml +5 -0
- data/README.md +40 -6
- data/lib/devise_yubikey_database_authenticatable/model.rb +15 -2
- data/lib/devise_yubikey_database_authenticatable/routes.rb +3 -3
- data/lib/devise_yubikey_database_authenticatable/strategy.rb +12 -6
- data/lib/devise_yubikey_database_authenticatable/version.rb +1 -1
- data/lib/yubikey_database_authenticatable.rb +22 -1
- data/yubikey_database_authenticatable.gemspec +2 -5
- metadata +19 -61
- data/test/test_helper.rb +0 -3
- data/test/yubikey_database_authenticatable_test.rb +0 -8
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0ab72d31d010db0aac6291cdf69f5a19416f699a
|
4
|
+
data.tar.gz: b962124a75f6e5c89516d82a6f2017674f4a7051
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 42cc52823fc3d51e401700b338ba89503515f6fa6f721599ce6bc17276c500990272af5e7645b0031005e1f80dbf8bef5e0e31b9e6fc298354644ef8caa298c9
|
7
|
+
data.tar.gz: da14938286525920db67a58e515fa949b4a327d7c32b9248801ca3ef095e8cd738e155d5440d32a785932945a9b24aabad35457c37a013e55bae311e313aaff6
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# Devise - Yubikey Database Authentication
|
2
|
+
|
3
|
+
[](https://travis-ci.org/mort666/yubikey_database_authenticatable)
|
2
4
|
|
3
5
|
This extension to Devise adds a modified Database Authentication strategy to allow the authentication of a user with Two Factor Authentication provided by the Yubikey OTP token
|
4
6
|
|
@@ -6,9 +8,9 @@ This extension requires the used to already have a valid account and password an
|
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
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.
|
11
|
+
This plugin requires Rails 4.x, 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
12
|
|
11
|
-
|
13
|
+
[https://github.com/titanous/yubikey](https://github.com/titanous/yubikey)
|
12
14
|
|
13
15
|
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.
|
14
16
|
|
@@ -20,25 +22,30 @@ The gem for the Yubikey library will need to be added to your Gemfile. To instal
|
|
20
22
|
|
21
23
|
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.
|
22
24
|
|
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 (
|
25
|
+
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 (`config/initializers/devise.rb`).
|
24
26
|
|
25
|
-
Get a key here:
|
27
|
+
Get a key here: [https://upgrade.yubico.com/getapikey/](https://upgrade.yubico.com/getapikey/)
|
26
28
|
|
29
|
+
``` ruby
|
27
30
|
config.yubikey_api_key = "" # => API Key must be set to validate one time passwords
|
28
31
|
config.yubikey_api_id = "" # => API ID must be set to validate one time passwords
|
32
|
+
```
|
29
33
|
|
30
34
|
The following needs to be added to the User module.
|
31
35
|
|
36
|
+
``` ruby
|
32
37
|
add_column :users, :use_yubikey, :boolean
|
33
38
|
add_column :users, :registered_yubikey, :string
|
39
|
+
```
|
34
40
|
|
35
41
|
then finally add to the model:
|
36
42
|
|
43
|
+
``` ruby
|
37
44
|
class User < ActiveRecord::Base
|
38
45
|
|
39
46
|
devise :yubikey_database_authenticatable, :trackable, :timeoutable
|
40
47
|
|
41
|
-
# Setup accessible (or protected) attributes for your model
|
48
|
+
# Setup accessible (or protected) attributes for your model if using rails 3 or lower
|
42
49
|
attr_accessible :use_yubikey, :registered_yubikey, :yubiotp
|
43
50
|
|
44
51
|
attr_accessor :yubiotp
|
@@ -49,7 +56,34 @@ then finally add to the model:
|
|
49
56
|
|
50
57
|
...
|
51
58
|
end
|
59
|
+
```
|
60
|
+
|
61
|
+
If using rails 4, the params are controlled by strong params and need to be updated in your application_controller.rb. The following settings reflect a devise config allowing username or email and password or yubikey
|
62
|
+
|
63
|
+
``` ruby
|
64
|
+
before_filter :configure_permitted_parameters, if: :devise_controller?
|
65
|
+
|
66
|
+
protected
|
67
|
+
def configure_permitted_parameters
|
68
|
+
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation) }
|
69
|
+
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:username, :email, :password, :login, :use_yubikey, :registered_yubikey, :yubiotp) }
|
70
|
+
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
## Local Verifier
|
75
|
+
|
76
|
+
If you're using a local Yubikey verifier (rather than the YubiCloud verifier) you'll need to specify the following in `config/initializers/devise.rb`:
|
77
|
+
|
78
|
+
``` ruby
|
79
|
+
config.yubikey_api_url = "" # => API Verifier URL
|
80
|
+
config.yubikey_certificate_chain = "" # => Path to SSL cert for verifier
|
81
|
+
```
|
82
|
+
|
83
|
+
While a local verifier may work without an API key, you must use one per the upstream Yubikey module. If you're using the ykval server, ensure your database has a valid API ID and secret in the `clients` table.
|
52
84
|
|
53
85
|
## Copyright
|
54
86
|
|
55
|
-
Copyright (c) 2011 Stephen Kapp, Released under MIT License
|
87
|
+
Copyright (c) 2011-2015 Stephen Kapp, Released under MIT License
|
88
|
+
|
89
|
+
Some bits borrowed from moneytree fork of original gem.
|
@@ -13,7 +13,20 @@ require 'bcrypt'
|
|
13
13
|
|
14
14
|
def validate_yubikey(yubiotp)
|
15
15
|
begin
|
16
|
-
|
16
|
+
if Devise.yubikey_api_url && Devise.yubikey_certificate_chain
|
17
|
+
# If you've got your own API URL, you should have your own cert
|
18
|
+
# chain, too. If not, you'll use the default one for Yubicloud
|
19
|
+
# that is included in the Yubikey gem.
|
20
|
+
otp = Yubikey::OTP::Verify.new(:otp => yubiotp,
|
21
|
+
:api_id => Devise.yubikey_api_id,
|
22
|
+
:api_key => Devise.yubikey_api_key,
|
23
|
+
:url => Devise.yubikey_api_url,
|
24
|
+
:certificate_chain => :Devise.yubikey_certificate_chain)
|
25
|
+
else
|
26
|
+
otp = Yubikey::OTP::Verify.new(:otp => yubiotp,
|
27
|
+
:api_id => Devise.yubikey_api_id,
|
28
|
+
:api_key => Devise.yubikey_api_key)
|
29
|
+
end
|
17
30
|
|
18
31
|
if otp.valid?
|
19
32
|
return true
|
@@ -97,4 +110,4 @@ require 'bcrypt'
|
|
97
110
|
end
|
98
111
|
|
99
112
|
end
|
100
|
-
end
|
113
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
ActionDispatch::Routing::Mapper.class_eval do
|
2
2
|
protected
|
3
|
-
|
4
|
-
|
3
|
+
alias_method :devise_yubikey_database_authenticatable, :devise_session
|
4
|
+
end
|
@@ -4,13 +4,17 @@ module Devise
|
|
4
4
|
module Strategies
|
5
5
|
class YubikeyDatabaseAuthenticatable < Authenticatable
|
6
6
|
def authenticate!
|
7
|
-
resource =
|
7
|
+
resource = mapping.to.find_for_yubikey_database_authentication(authentication_hash)
|
8
8
|
return fail(:not_found_in_database) unless resource
|
9
9
|
|
10
|
-
if validate(resource)
|
11
|
-
if resource.use_yubikey
|
10
|
+
if validate(resource)
|
11
|
+
if resource.use_yubikey?
|
12
12
|
if params[scope][:yubiotp].blank?
|
13
|
-
|
13
|
+
if resource.valid_password?(password)
|
14
|
+
success!(resource)
|
15
|
+
else
|
16
|
+
fail(:invalid)
|
17
|
+
end
|
14
18
|
else
|
15
19
|
if resource.validate_yubikey(params[scope][:yubiotp]) && (resource.registered_yubikey == params[scope][:yubiotp][0..11])
|
16
20
|
resource.after_database_authentication
|
@@ -19,8 +23,10 @@ module Devise
|
|
19
23
|
fail('Invalid Yubikey OTP.')
|
20
24
|
end
|
21
25
|
end
|
22
|
-
|
26
|
+
elsif resource.valid_password?(password)
|
23
27
|
success!(resource)
|
28
|
+
else
|
29
|
+
fail(:invalid)
|
24
30
|
end
|
25
31
|
else
|
26
32
|
fail(:invalid)
|
@@ -30,4 +36,4 @@ module Devise
|
|
30
36
|
end
|
31
37
|
end
|
32
38
|
|
33
|
-
Warden::Strategies.add(:yubikey_database_authenticatable, Devise::Strategies::YubikeyDatabaseAuthenticatable)
|
39
|
+
Warden::Strategies.add(:yubikey_database_authenticatable, Devise::Strategies::YubikeyDatabaseAuthenticatable)
|
@@ -24,6 +24,27 @@ module Devise
|
|
24
24
|
# config.yubikey_api_id = "" # => Api ID must be set to validate one time passwords
|
25
25
|
mattr_accessor :yubikey_api_id
|
26
26
|
@@yubikey_api_id = nil
|
27
|
+
|
28
|
+
# Public: The api_url for a yubikey validation endpoint
|
29
|
+
# If you're not using the Yubikey cloud, you'll need to set this. Otherwise,
|
30
|
+
# the YubiKey gem will take care of it.
|
31
|
+
# If you need this, set yubikey_api_url in the Devise configuration file
|
32
|
+
# (config/initializers/devise.rb).
|
33
|
+
#
|
34
|
+
# config.yubikey_api_url = "" # => API URL of verifier
|
35
|
+
mattr_accessor :yubikey_api_url
|
36
|
+
@@yubikey_api_url = nil
|
37
|
+
|
38
|
+
# Public: The certificate_chain location for SSL validation
|
39
|
+
# If you're using your own verifier (you've specified yubikey_api_url) it's
|
40
|
+
# important that you pass the path to a verification chain for the CA or
|
41
|
+
# other certificates involved. If you need this, set
|
42
|
+
# yubikey_certificate_chain in the Devise configuration file
|
43
|
+
# (config/initializers/devise.rb).
|
44
|
+
#
|
45
|
+
# config.yubikey_certificate_chain = "" # => API Cert Chain File
|
46
|
+
mattr_accessor :yubikey_certificate_chain
|
47
|
+
@@yubikey_certificate_chain = nil
|
27
48
|
end
|
28
49
|
|
29
|
-
Devise.add_module(:yubikey_database_authenticatable, :strategy => true, :model => "devise_yubikey_database_authenticatable/model", :route => :session, :controller => :sessions)
|
50
|
+
Devise.add_module(:yubikey_database_authenticatable, :strategy => true, :model => "devise_yubikey_database_authenticatable/model", :route => :session, :controller => :sessions)
|
@@ -10,7 +10,6 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = 'Extended version of the Devise Database Authentication module to implement YubiKey OTP two factor authentication for registered users'
|
11
11
|
s.email = 'mort666@virus.org'
|
12
12
|
s.homepage = 'https://github.com/mort666/yubikey_database_authenticatable'
|
13
|
-
s.description = s.summary
|
14
13
|
s.authors = ['Stephen Kapp']
|
15
14
|
|
16
15
|
s.files = `git ls-files`.split("\n")
|
@@ -19,8 +18,6 @@ Gem::Specification.new do |s|
|
|
19
18
|
s.require_paths = ["lib"]
|
20
19
|
|
21
20
|
s.add_dependency('devise', '>= 2.2.3')
|
22
|
-
s.add_dependency('yubikey', '~> 1.
|
21
|
+
s.add_dependency('yubikey', '~> 1.4.1')
|
23
22
|
s.add_development_dependency "active_support"
|
24
|
-
|
25
|
-
s.add_development_dependency "rdoc"
|
26
|
-
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,102 +1,65 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yubikey_database_authenticatable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Stephen Kapp
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-09-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: devise
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 2.2.3
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 2.2.3
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: yubikey
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.
|
33
|
+
version: 1.4.1
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.
|
40
|
+
version: 1.4.1
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: active_support
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
|
-
|
63
|
-
|
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'
|
94
|
-
description: YubiKey OTP Authentication Plugin for Devise
|
55
|
+
description: Extended version of the Devise Database Authentication module to implement
|
56
|
+
YubiKey OTP two factor authentication for registered users
|
95
57
|
email: mort666@virus.org
|
96
58
|
executables: []
|
97
59
|
extensions: []
|
98
60
|
extra_rdoc_files: []
|
99
61
|
files:
|
62
|
+
- ".travis.yml"
|
100
63
|
- MIT-LICENSE
|
101
64
|
- README.md
|
102
65
|
- Rakefile
|
@@ -106,33 +69,28 @@ files:
|
|
106
69
|
- lib/devise_yubikey_database_authenticatable/version.rb
|
107
70
|
- lib/yubikey_database_authenticatable.rb
|
108
71
|
- rails/init.rb
|
109
|
-
- test/test_helper.rb
|
110
|
-
- test/yubikey_database_authenticatable_test.rb
|
111
72
|
- yubikey_database_authenticatable.gemspec
|
112
73
|
homepage: https://github.com/mort666/yubikey_database_authenticatable
|
113
74
|
licenses: []
|
75
|
+
metadata: {}
|
114
76
|
post_install_message:
|
115
77
|
rdoc_options: []
|
116
78
|
require_paths:
|
117
79
|
- lib
|
118
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
81
|
requirements:
|
121
|
-
- -
|
82
|
+
- - ">="
|
122
83
|
- !ruby/object:Gem::Version
|
123
84
|
version: '0'
|
124
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
86
|
requirements:
|
127
|
-
- -
|
87
|
+
- - ">="
|
128
88
|
- !ruby/object:Gem::Version
|
129
89
|
version: '0'
|
130
90
|
requirements: []
|
131
91
|
rubyforge_project:
|
132
|
-
rubygems_version:
|
92
|
+
rubygems_version: 2.2.2
|
133
93
|
signing_key:
|
134
|
-
specification_version:
|
94
|
+
specification_version: 4
|
135
95
|
summary: YubiKey OTP Authentication Plugin for Devise
|
136
|
-
test_files:
|
137
|
-
- test/test_helper.rb
|
138
|
-
- test/yubikey_database_authenticatable_test.rb
|
96
|
+
test_files: []
|
data/test/test_helper.rb
DELETED