rack-u2f 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fadfe6cc870a2dbed3a6fcde4be9f7cb309ca2d0
4
- data.tar.gz: 562f528d75d8eeccc0901eed6367cb9bac0723e5
3
+ metadata.gz: 9fe4dca8a6f78e6aac6fd45545bed43a0171ebb6
4
+ data.tar.gz: 5ab1554a93134238528ca2b0a84e6f3e737e64e2
5
5
  SHA512:
6
- metadata.gz: 712654a48a465300d0af1a9f81456077e8f78f6f0b207c4691a37d27b09350490b353b517b7081f9ca8bd75bac5b0d9514910d25741adab6d24c6730573f8e8b
7
- data.tar.gz: 2dabffb61eb6ba305a610166f47a432364f5d60ddbd1215c656a2f3a8f57905967df08ca23145d513992a7b1c448be73b7a00f66f93f9b1113d1c41ce3b48bbe
6
+ metadata.gz: 0e0a3cceb8664c2d61a79feccdab3c758f3353d5736d676ba47a0149d8445073e93c4722750d48e92475b08779f6f8384e372d46fb63da42637f18110fafb410
7
+ data.tar.gz: 8b2ab1b65cc9a70be5d2d7d4457d155d9ed5b2457fb9c9606d6896f32df0c979886289fe0f1f01d8cc223eb4d67e273029b8b1cd026ffbe72ebefde0f85b1d63
@@ -25,7 +25,7 @@ module Rack
25
25
  private
26
26
 
27
27
  def excluded?(request)
28
- @exclude_urls.any?{ |exc| request.path =~ exc }
28
+ @exclude_urls.any? { |exc| request.path =~ exc }
29
29
  end
30
30
 
31
31
  def authenticated?(request)
@@ -33,11 +33,11 @@ module Rack
33
33
  end
34
34
 
35
35
  def resp_unregistered
36
- [403, {}, ["Unregistered Device"]]
36
+ Rack::Response.new('Unregistered Device', 403)
37
37
  end
38
38
 
39
39
  def resp_invalid
40
- [403, {}, ["Invalid Auth"]]
40
+ Rack::Response.new('Invalid Auth', 403)
41
41
  end
42
42
 
43
43
  def resp_auth_from_u2f(request)
@@ -47,9 +47,9 @@ module Rack
47
47
  begin
48
48
  u2f = U2F::U2F.new(extract_app_id(request))
49
49
  u2f.authenticate!(request.session['challenge'], u2f_response,
50
- Base64.decode64(registration['public_key']),
51
- registration['counter'])
52
- rescue U2F::Error => e
50
+ Base64.decode64(registration['public_key']),
51
+ registration['counter'])
52
+ rescue U2F::Error
53
53
  return resp_invalid
54
54
  ensure
55
55
  request.session.delete('challenge')
@@ -57,12 +57,12 @@ module Rack
57
57
 
58
58
  @store.update_registration(key_handle: u2f_response.key_handle, counter: u2f_response.counter)
59
59
  request.session['u2f_authenticated'] = true
60
- [302, { "Location" => @after_sign_in_path }, []]
60
+ [302, { 'Location' => @after_sign_in_path }, []]
61
61
  end
62
62
 
63
63
  def challenge_page(request)
64
64
  key_handles = @store.key_handles
65
- return resp_unregistered unless key_handles && key_handles.size > 0
65
+ return resp_unregistered unless key_handles && !key_handles.empty?
66
66
  u2f = U2F::U2F.new(extract_app_id(request))
67
67
  sign_requests = u2f.authentication_requests(key_handles)
68
68
  challenge = u2f.challenge
@@ -11,7 +11,6 @@ module Rack
11
11
  @config = config
12
12
  @store = config[:store]
13
13
  @registration_enabled = config[:enable_registration]
14
- raise 'Missing RegistrationMiddleware Config' if @config.nil?
15
14
  end
16
15
 
17
16
  def call(env)
@@ -46,7 +45,7 @@ module Rack
46
45
  end
47
46
 
48
47
  def generate_registration(request)
49
- u2f = U2F::U2F.new('https://junk.ngrok.io')
48
+ u2f = U2F::U2F.new(extract_app_id(request))
50
49
  registration_requests = u2f.registration_requests
51
50
  request.session['challenges'] = registration_requests.map(&:challenge)
52
51
  key_handles = @store.key_handles
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module U2f
3
- VERSION = '0.1.3'.freeze
3
+ VERSION = '0.1.4'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-u2f
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eaden McKee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-09 00:00:00.000000000 Z
11
+ date: 2017-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache