rack-u2f 0.1.0 → 0.1.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 +4 -4
- data/README.md +14 -7
- data/lib/rack/u2f/authentication_middleware.rb +4 -1
- data/lib/rack/u2f/helpers.rb +0 -1
- data/lib/rack/u2f/registration_server.rb +1 -1
- data/lib/rack/u2f/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75385507e44ffd51443e6d4a864251a72cbf9724
|
4
|
+
data.tar.gz: 3d20699e67ed4f01aa90177111d1b8dddd786a9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df5d4356775a6eb09cd2ed8a816a74359bbd666b111575a587e56f47a059c0ae9712ef4c6389afed2222c1748186110647c5a575a694743e4dcd5b1529814a2e
|
7
|
+
data.tar.gz: f3e91e2bee2371b14c40eb1a7ed4ef15847d004603bc9f51938d4e0796b13baeb2ef2233166705d205c0efc0d53c34afc8e393b8001821799f00a7032b2c34c7
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Note: This gem needs a tidy up and will be properly released by end of Nov 2017
|
4
4
|
|
5
|
+
[](https://badge.fury.io/rb/rack-u2f)
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
@@ -26,23 +28,28 @@ Rack middleware to authenticate against registered U2F devices
|
|
26
28
|
|
27
29
|
In rails:
|
28
30
|
|
29
|
-
In `config/routes.rb`:
|
30
|
-
|
31
|
-
```ruby
|
32
|
-
mount Rack::U2f::RegistrationServer.new(store: Rack::U2f::RegistrationStore::RedisStore.new), at: '/u2f_registration'
|
33
|
-
```
|
34
|
-
|
35
31
|
in `config/application.rb`
|
36
32
|
|
37
33
|
```ruby
|
38
34
|
config.middleware.use Rack::U2f::AuthenticationMiddleware, {
|
39
35
|
store: Rack::U2f::RegistrationStore::RedisStore.new,
|
40
|
-
exclude_urls: [/\Au2f/, /\A\/\z/]
|
36
|
+
exclude_urls: [/\Au2f/, /\A\/\z/],
|
37
|
+
enable_registration: ENV['ENABLE_U2F_REGISTRATION'] == "true",
|
38
|
+
after_sign_in_url: '/', # optional, defaults to '/'
|
39
|
+
u2f_register_path: '/_u2f_register' #optional, defaults to '/_u2f_register'
|
41
40
|
}
|
42
41
|
```
|
43
42
|
|
44
43
|
Currently only a redis store is developed, but other stores such as active record will be easy to add.
|
45
44
|
|
45
|
+
if `enable_registration` is set to `"true"` then you will be able to visit `/_u2f_register` to register a new key.
|
46
|
+
|
47
|
+
Note: U2F only works on *https* connections.
|
48
|
+
|
49
|
+
In addition, the registration depends on the url used to register, so data from one environment will not work on another.
|
50
|
+
|
51
|
+
When authenticated, the session is used to store that fact. *You must be using a secure session store*.
|
52
|
+
|
46
53
|
## Development
|
47
54
|
|
48
55
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -6,13 +6,16 @@ module Rack
|
|
6
6
|
|
7
7
|
def initialize(app, config = nil)
|
8
8
|
@app = app
|
9
|
+
@config = config
|
10
|
+
@u2f_register_path = config[:u2f_register_path] || '/_u2f_register'
|
9
11
|
@store = config[:store] || raise('Please specify a U2F store such as Rack::U2f::RegistrationStore::RedisStore.new')
|
10
|
-
@exclude_urls = config[:exclude_urls] || [
|
12
|
+
@exclude_urls = config[:exclude_urls] || []
|
11
13
|
end
|
12
14
|
|
13
15
|
def call(env)
|
14
16
|
request = Rack::Request.new(env)
|
15
17
|
return @app.call(env) if excluded?(request)
|
18
|
+
return RegistrationServer.new(@config).call(env) if request.path == '/_u2f_register'
|
16
19
|
return @app.call(env) if authenticated?(request)
|
17
20
|
return resp_auth_from_u2f(request) if request.params['u2f_auth']
|
18
21
|
challenge_page(request)
|
data/lib/rack/u2f/helpers.rb
CHANGED
@@ -14,7 +14,7 @@ module Rack
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def call(env)
|
17
|
-
return [403, {}, ['']] unless
|
17
|
+
return [403, {}, ['Registration Disabled']] unless @config[:enable_registration]
|
18
18
|
request = Rack::Request.new(env)
|
19
19
|
if request.get?
|
20
20
|
generate_registration(request)
|
data/lib/rack/u2f/version.rb
CHANGED