diff --git a/Gemfile.lock b/Gemfile.lock
index ddfb09b..33297e2 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- u2f (0.2.1)
+ u2f (1.0.0)
GEM
remote: https://rubygems.org/
@@ -82,4 +82,4 @@ DEPENDENCIES
u2f!
BUNDLED WITH
- 1.11.0
+ 1.12.3
diff --git a/example/Gemfile b/example/Gemfile
index 73e40be..8157f7b 100644
--- a/example/Gemfile
+++ b/example/Gemfile
@@ -17,4 +17,7 @@ gem 'dm-core'
# Padrino Stable Gem
gem 'padrino', '0.12.4'
+# To enable https
+gem 'thin'
+
gem 'u2f'#, path: '../.'
diff --git a/example/Gemfile.lock b/example/Gemfile.lock
index 227ba34..6233a1e 100644
--- a/example/Gemfile.lock
+++ b/example/Gemfile.lock
@@ -11,6 +11,7 @@ GEM
bcrypt (3.1.9)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
+ daemons (1.2.4)
data_objects (0.10.14)
addressable (~> 2.1)
dm-aggregates (1.2.0)
@@ -41,6 +42,7 @@ GEM
dm-core (~> 1.2.0)
do_sqlite3 (0.10.14)
data_objects (= 0.10.14)
+ eventmachine (1.2.3)
fastercsv (1.5.5)
haml (4.0.5)
tilt
@@ -100,6 +102,10 @@ GEM
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
stringex (1.5.1)
+ thin (1.7.0)
+ daemons (~> 1.0, >= 1.0.9)
+ eventmachine (~> 1.0, >= 1.0.4)
+ rack (>= 1, < 3)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
@@ -128,4 +134,8 @@ DEPENDENCIES
haml
padrino (= 0.12.4)
rake
+ thin
u2f
+
+BUNDLED WITH
+ 1.12.3
diff --git a/example/README.md b/example/README.md
index f0b8d23..39a84dd 100644
--- a/example/README.md
+++ b/example/README.md
@@ -1,5 +1,5 @@
```bash
bundle install
padrino rake db:migrate
-padrino start
+thin start --ssl --ssl-disable-verify
```
diff --git a/example/app/controllers/registrations.rb b/example/app/controllers/registrations.rb
index 67b0f49..2e68fe1 100644
--- a/example/app/controllers/registrations.rb
+++ b/example/app/controllers/registrations.rb
@@ -12,19 +12,19 @@
post :index do
response = U2F::RegisterResponse.load_from_json(params[:response])
- reg = begin
- u2f.register!(session[:challenges], response)
+ begin
+ reg = u2f.register!(session[:challenges], response)
+
+ Registration.create!(certificate: reg.certificate,
+ key_handle: reg.key_handle,
+ public_key: reg.public_key,
+ counter: reg.counter)
rescue U2F::Error => e
@error_message = "Unable to register: #{e.class.name}"
ensure
session.delete(:challenges)
end
- Registration.create!(certificate: reg.certificate,
- key_handle: reg.key_handle,
- public_key: reg.public_key,
- counter: reg.counter)
-
render 'authentications/show'
end
end
diff --git a/example/app/views/authentications/new.haml b/example/app/views/authentications/new.haml
index ebac786..d7abc18 100644
--- a/example/app/views/authentications/new.haml
+++ b/example/app/views/authentications/new.haml
@@ -33,8 +33,10 @@
$error.style.display = 'block';
$error.innerHTML = errorMap[code];
};
+ var appId = signRequests[0].appId
+ var challenge = signRequests[0].challenge
- u2f.sign(signRequests, function(signResponse) {
+ u2f.sign(appId, challenge, signRequests, function(signResponse) {
var form, reg;
if (signResponse.errorCode) {
diff --git a/example/app/views/layouts/application.html.erb b/example/app/views/layouts/application.html.erb
index aab2f88..27f0dfa 100644
--- a/example/app/views/layouts/application.html.erb
+++ b/example/app/views/layouts/application.html.erb
@@ -11,12 +11,12 @@
<%= stylesheet_link_tag '//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css' %>
-
+
-
<%= javascript_include_tag 'application' %>
+ <%= javascript_include_tag 'u2f-api' %>