web_authn 0.1.0 → 0.1.1

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
- SHA1:
3
- metadata.gz: 90fa59a9c5c84e8af4b97f36556519d95bb90a2d
4
- data.tar.gz: 1fa4312c262df939a5206beac7649aa95c2cd3ed
2
+ SHA256:
3
+ metadata.gz: 89d25f455fdd1323936c0c32072be162f888df15e7ddd86fb65549e9f37736fb
4
+ data.tar.gz: ecb31a66853aeaca039da91aeb66ca5a24b5ee9f103153ed76ae6593fc1071ea
5
5
  SHA512:
6
- metadata.gz: 40d5722f816201ed293e16c43761b58583278ab66ffd39b1065bb8ef022730ab55d4ae02ef35851f9e87e26745f9dea9ccc5ce381c2727ce27e370180708211e
7
- data.tar.gz: '04638e31e160fa8267975af7c3d152428a6485ea8724049d62a8a1e6b5d2e651732863c0c43fc74ff8a1dfc294c0543efc145e6c80ec08e6a0a820643d8cfba9'
6
+ metadata.gz: dee33babaf79b1ba80f86321223206c56e59c7c3e5adc113bb8a4f51d8d9c185d5eb1b62219a408e98130265d75e9ee1fa648794d3db8f60ab32551cbd5c83bb
7
+ data.tar.gz: 70fdbe9c79f25a5044eea4ac2b06815d6f5c128e0db61c03f930577cba78dc2d5e6fcf46324823fefa9dcefab2b76ccd648e3e769a12020f123f7f0d128b7798
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # WebAuthn
2
2
 
3
- W3C WebAuthn (a.k.a. FIDO2) RP library in Ruby
3
+ W3C Web Authentication API (a.k.a. WebAuthN / FIDO 2.0) RP library in Ruby
4
4
 
5
5
  [![Build Status](https://secure.travis-ci.org/nov/web_authn.png)](http://travis-ci.org/nov/web_authn)
6
6
 
@@ -14,11 +14,15 @@ gem 'web_authn'
14
14
 
15
15
  And then execute:
16
16
 
17
- $ bundle
17
+ ```sh
18
+ $ bundle
19
+ ```
18
20
 
19
21
  Or install it yourself as:
20
22
 
21
- $ gem install web_authn
23
+ ```sh
24
+ $ gem install web_authn
25
+ ```
22
26
 
23
27
  ## Usage
24
28
 
@@ -33,11 +37,11 @@ Currently, there are several restrictions.
33
37
 
34
38
  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.
35
39
 
36
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `VERSION`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
37
41
 
38
42
  ## Contributing
39
43
 
40
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/web_authn.
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nov/web_authn.
41
45
 
42
46
  ## License
43
47
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "web_authn"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -16,35 +16,15 @@ module WebAuthn
16
16
  )
17
17
  aaguid,
18
18
  credential_id,
19
- _encoded_cose_key_ = [
19
+ cose_key_cbor = [
20
20
  attested_credential_data.byteslice(0...16),
21
21
  attested_credential_data.byteslice(18...(18 + length)),
22
22
  attested_credential_data.byteslice((18 + length)..-1),
23
23
  ]
24
- cose_key = COSE::Key::EC2.from_cbor(_encoded_cose_key_)
25
- curve_name = case cose_key.curve
26
- when 1
27
- 'prime256v1'
28
- when 2
29
- 'secp384r1'
30
- when 3
31
- 'secp521r1'
32
- else
33
- raise NotImplementedError, 'Non-supported EC curve'
34
- end
35
- ec_key = OpenSSL::PKey::EC.new curve_name
36
- ec_key.public_key = OpenSSL::PKey::EC::Point.new(
37
- OpenSSL::PKey::EC::Group.new(curve_name),
38
- OpenSSL::BN.new([
39
- '04' +
40
- cose_key.x_coordinate.unpack('H*').first +
41
- cose_key.y_coordinate.unpack('H*').first
42
- ].pack('H*'), 2)
43
- )
44
24
  new(
45
25
  aaguid: Base64.urlsafe_encode64(aaguid, padding: false),
46
26
  credential_id: Base64.urlsafe_encode64(credential_id, padding: false),
47
- public_key: ec_key
27
+ public_key: COSE::Key.decode(cose_key_cbor).to_key
48
28
  )
49
29
  end
50
30
  end
@@ -40,6 +40,9 @@ module WebAuthn
40
40
  end
41
41
 
42
42
  def verify_signature!(public_key, signature)
43
+ # TODO:
44
+ # needs to handle digest size based on COSE key algorithm.
45
+ # how to get COSE key alg header at this point?
43
46
  signature_base_string = [
44
47
  authenticator_data.raw,
45
48
  OpenSSL::Digest::SHA256.digest(client_data_json.raw)
data/lib/web_authn.rb CHANGED
@@ -2,8 +2,7 @@ require 'openssl'
2
2
  require 'active_support'
3
3
  require 'active_support/core_ext'
4
4
  require 'cbor'
5
- require 'cose'
6
- require 'cose/key/ec2'
5
+ require 'cose/key'
7
6
 
8
7
  module WebAuthn
9
8
  class Exception < StandardError; end
data/web_authn.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.required_ruby_version = '>= 2.3'
15
15
  gem.add_runtime_dependency 'activesupport'
16
16
  gem.add_runtime_dependency 'cbor'
17
- gem.add_runtime_dependency 'cose'
17
+ gem.add_runtime_dependency 'cose-key'
18
18
  gem.add_development_dependency 'rake', '~> 10.0'
19
19
  gem.add_development_dependency 'simplecov'
20
20
  gem.add_development_dependency 'rspec'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_authn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-07 00:00:00.000000000 Z
11
+ date: 2018-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: cose
42
+ name: cose-key
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -112,7 +112,9 @@ description: W3C Web Authentication API (a.k.a. WebAuthN / FIDO 2.0) RP library
112
112
  Ruby
113
113
  email:
114
114
  - nov@matake.jp
115
- executables: []
115
+ executables:
116
+ - console
117
+ - setup
116
118
  extensions: []
117
119
  extra_rdoc_files: []
118
120
  files:
@@ -124,6 +126,8 @@ files:
124
126
  - README.md
125
127
  - Rakefile
126
128
  - VERSION
129
+ - bin/console
130
+ - bin/setup
127
131
  - lib/web_authn.rb
128
132
  - lib/web_authn/attestation_object.rb
129
133
  - lib/web_authn/attested_credential_data.rb
@@ -163,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
167
  version: '0'
164
168
  requirements: []
165
169
  rubyforge_project:
166
- rubygems_version: 2.6.11
170
+ rubygems_version: 2.7.6
167
171
  signing_key:
168
172
  specification_version: 4
169
173
  summary: WebAuthn RP library