Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace chrome-extension with u2f-api.js from Google's github. #30

Merged
merged 1 commit into from
Apr 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
u2f (0.2.1)
u2f (1.0.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -82,4 +82,4 @@ DEPENDENCIES
u2f!

BUNDLED WITH
1.11.0
1.12.3
3 changes: 3 additions & 0 deletions example/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ gem 'dm-core'
# Padrino Stable Gem
gem 'padrino', '0.12.4'

# To enable https
gem 'thin'

gem 'u2f'#, path: '../.'
10 changes: 10 additions & 0 deletions example/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -128,4 +134,8 @@ DEPENDENCIES
haml
padrino (= 0.12.4)
rake
thin
u2f

BUNDLED WITH
1.12.3
2 changes: 1 addition & 1 deletion example/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```bash
bundle install
padrino rake db:migrate
padrino start
thin start --ssl --ssl-disable-verify
```
14 changes: 7 additions & 7 deletions example/app/controllers/registrations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion example/app/views/authentications/new.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions example/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1">

<%= stylesheet_link_tag '//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css' %>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700' rel='stylesheet' type='text/css'>
<style type="text/css">
body { font-family: 'Source Sans Pro', sans-serif; }
</style>
<script src="chrome-extension://pfboblefjcgdjicmnffhdgionmgcdmne/u2f-api.js"></script>
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag 'u2f-api' %>
</head>
<body>
<!--[if lt IE 7]>
Expand Down
3 changes: 2 additions & 1 deletion example/app/views/registrations/new.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
$error.style.display = 'block';
$error.innerHTML = errorMap[code];
};
var appId = registerRequests[0].appId

u2f.register(registerRequests, signRequests, function(registerResponse) {
u2f.register(appId, registerRequests, signRequests, function(registerResponse) {
var form, reg;

if (registerResponse.errorCode) {
Expand Down
Loading