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

WIP: Upstream updates #1

Draft
wants to merge 75 commits into
base: from_hash
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
2fbc79e
Fix URL path
otms61 Mar 20, 2017
54cf4ba
Merge pull request #29 from otms61/API_v1_1
wallin Mar 20, 2017
921aeb7
Replace chrome-extension with u2f-api.js from Google's github. (#30)
alokmenghrajani Apr 4, 2017
82bac92
Code cleanup (#33)
snood1205 May 4, 2017
16fbd3d
Example and doc fixups (#35)
rst Jun 9, 2017
60671f7
Validate the JSON data in load (#36)
ashleym1972 Dec 14, 2017
a525e7a
Upgrade gems and fix styling issues (#37)
wallin Dec 17, 2017
ec7eae3
Fix documentation for U2F.authenticate!: First argument is a single c…
lgarron Sep 6, 2018
64814e2
Upgrade gems 2018-09-06 (#39)
wallin Sep 6, 2018
8972724
cleanup ruby versions
nijikon Sep 23, 2018
fbd46a6
Merge pull request #40 from castle/cleanup-ruby-versions
nijikon Sep 23, 2018
430b8cf
bump-gems-2018-10-03
nijikon Oct 3, 2018
11a631a
Merge pull request #42 from castle/bump-2018-10-03
nijikon Oct 4, 2018
90c373b
bump-gems-2018-10-15
nijikon Oct 15, 2018
bb208c4
Merge pull request #43 from castle/bump-2018-10-15
nijikon Oct 16, 2018
9dea2dc
bump-gems-2018-11-06
nijikon Nov 6, 2018
8e3915b
Merge pull request #44 from castle/bump-2018-11-06
nijikon Nov 6, 2018
41d955f
drop support for ruby 2.2
nijikon Sep 23, 2018
c7bc023
fix Style/RedundantFreeze
nijikon Sep 23, 2018
58eed68
fix Bundler/OrderedGems
nijikon Sep 23, 2018
4abd28d
Merge pull request #41 from castle/drop-support-for-ruby-2.2
nijikon Jan 19, 2019
5d7d0df
bump ruby versions and add coditsu v2
nijikon Jan 19, 2019
fd0def5
Merge pull request #50 from castle/update-ruby-versions
nijikon Jan 19, 2019
08f1324
add changelog
nijikon Jan 19, 2019
10c32c6
move version to proper location
nijikon Jan 19, 2019
c4e98b3
Merge pull request #51 from castle/move-version-to-proper-location
nijikon Jan 19, 2019
940daa7
bump-gems-2019-01-19
nijikon Jan 19, 2019
cf70859
drop rubocop in favor of coditsu
nijikon Jan 19, 2019
94e5017
Merge pull request #52 from castle/bump-2019-01-19
nijikon Jan 19, 2019
831baf8
fix Style/ExpandPathArguments
nijikon Jan 19, 2019
48d0e73
fix Style/IfUnlessModifier
nijikon Jan 19, 2019
1fa9621
fix Layout/EmptyLineAfterGuardClause
nijikon Jan 19, 2019
59b3cf2
fix Style/NumericPredicate
nijikon Jan 19, 2019
b8e9b8b
fix RSpec/EmptyLineAfterFinalLet
nijikon Jan 19, 2019
17c411f
fix Style/SafeNavigation
nijikon Jan 19, 2019
03eee7a
fix RSpec/NotToNot
nijikon Jan 19, 2019
fbb9431
fix RSpec/EmptyLineAfterExampleGroup
nijikon Jan 19, 2019
9da1f76
fix Layout/ExtraSpacing
nijikon Jan 19, 2019
7422bc6
fix Layout/SpaceAroundOperators
nijikon Jan 19, 2019
febcc57
Merge pull request #53 from castle/rubocop-fixes
nijikon Jan 19, 2019
e16dc50
bump-gems-2019-02-25
nijikon Feb 25, 2019
42cdb1d
Merge pull request #54 from castle/bump-2019-02-25
nijikon Feb 25, 2019
156fcf6
test against ruby 2.6.1
nijikon Mar 11, 2019
536d1be
cleanup
nijikon Mar 11, 2019
1daa303
Merge pull request #55 from castle/ruby-2.6.1
nijikon Mar 11, 2019
99a05eb
fix coditsu
nijikon May 15, 2019
c0318fe
Merge pull request #57 from castle/fix-coditsu
nijikon May 15, 2019
a7faf71
update ruby versions
nijikon May 15, 2019
182b748
Merge pull request #58 from castle/update-ruby-versions
nijikon May 15, 2019
2c9e038
update coditsu integration
nijikon Jun 10, 2019
01d27a0
Merge pull request #59 from castle/update-coditsu
nijikon Jun 10, 2019
02048cf
bump-gems-2019-06-10
nijikon Jun 10, 2019
6ffc401
Merge pull request #60 from castle/bump-gems-2019-06-10
nijikon Jun 10, 2019
ef9f681
bump-gems-2019-06-25
nijikon Jun 25, 2019
d3f570a
Merge pull request #61 from castle/bump-2019-06-25
nijikon Jun 25, 2019
df242a2
Update example link in README (#62)
joshneipp Aug 2, 2019
e5626c2
bump-gems-2019-09-05
nijikon Sep 5, 2019
e4c1e2c
Merge pull request #63 from castle/bump-2019-09-05
nijikon Sep 6, 2019
e0daea5
bump-gems-2019-10-14
nijikon Oct 14, 2019
308e1fc
update ruby versions
nijikon Oct 14, 2019
4644bc2
Merge pull request #64 from castle/bump-2019-10-14
nijikon Oct 14, 2019
d9d64cf
bump-gems-2019-11-06
nijikon Nov 6, 2019
c5ab7a9
Merge pull request #65 from castle/bump-2019-11-06
nijikon Nov 7, 2019
730bb71
bump-gems-2019-11-17
nijikon Nov 17, 2019
4c192ea
Merge pull request #66 from castle/bump-2019-11-17
nijikon Nov 17, 2019
ac52fe8
bump-gems-2020-03-02
nijikon Mar 2, 2020
b2ff1aa
Merge pull request #68 from castle/bump-2020-03-02
nijikon Mar 2, 2020
96831b1
bump-gems-2020-05-21
nijikon May 21, 2020
e29c24a
Merge pull request #69 from castle/bump-2020-05-21
nijikon May 21, 2020
5bebd7f
Update some dependencies
afterdesign Mar 30, 2023
1958e51
Merge pull request #72 from castle/update-dependencies
afterdesign Mar 30, 2023
e9bd062
Update dependencies
afterdesign Mar 30, 2023
f7100e6
Merge pull request #73 from castle/update-dependencies
afterdesign Mar 30, 2023
0f14185
Bump rack from 2.2.6.4 to 2.2.9 in /example (#75)
dependabot[bot] Jun 3, 2024
38bba87
chore: manually merge custom fork with upstream
joe-herman Aug 4, 2024
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
3 changes: 3 additions & 0 deletions .coditsu/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
repository_id: 'f789891f-3f4e-42be-a25b-068d49708ddb'
api_key: <%= ENV['CODITSU_API_KEY'] %>
api_secret: <%= ENV['CODITSU_API_SECRET'] %>
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@
.rvmrc

# Example files
/example/.bundle
/example/.bundle
vendor
.coditsu/local.yml
15 changes: 15 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Documentation:
Enabled: false
AllCops:
TargetRubyVersion: 2.6

Metrics/LineLength:
Max: 100

Metrics/ModuleLength:
Exclude:
- "**/*_spec.rb"

Metrics/BlockLength:
Exclude:
- "**/*_spec.rb"
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.5
53 changes: 47 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
language: ruby
rvm:
- 2.0.0
- 2.1.8
- 2.2.4
- 2.3.0
services:
- docker

dist: trusty
sudo: false
cache: bundler

git:
depth: false

test: &test
stage: test
language: ruby
before_install:
- gem install bundler
- gem update --system

jobs:
include:
- <<: *test
rvm: 2.6.5
- <<: *test
rvm: 2.5.7
- <<: *test
rvm: 2.4.8

- stage: coditsu
language: ruby
rvm: 2.6.3
before_install:
- gem update --system
- gem install bundler
before_script:
- docker create -v /sources --name sources alpine:3.4 /bin/true
- docker cp ./ sources:/sources
script: >
docker run
-e CODITSU_API_KEY
-e CODITSU_API_SECRET
-e CODITSU_REPOSITORY_ID
-e CODITSU_BUILD_BRANCH=$TRAVIS_BRANCH
--volumes-from sources
coditsu/build-runner:latest

stages:
- test
- coditsu
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## master
- [#58](https://github.com/castle/ruby-u2f/pull/58) drop support for ruby 2.3
- [#41](https://github.com/castle/ruby-u2f/pull/41) drop support for ruby 2.2

## 1.0.0 (2016-02-18)
- update ruby-u2f to work with the v1.1 U2F JavaScript API.
13 changes: 12 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
source "https://rubygems.org"
# frozen_string_literal: true

source 'https://rubygems.org'
gemspec

gem 'rake'

group :test do
gem 'coveralls_reborn'
gem 'json_expressions'
gem 'rspec'
gem 'simplecov'
end
105 changes: 37 additions & 68 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,85 +1,54 @@
PATH
remote: .
specs:
u2f (0.2.1)
u2f (1.0.0)

GEM
remote: https://rubygems.org/
specs:
ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
coveralls (0.8.10)
json (~> 1.8)
rest-client (>= 1.6.8, < 2)
simplecov (~> 0.11.0)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
tins (~> 1.6.0)
diff-lcs (1.2.5)
docile (1.1.5)
domain_name (0.5.25)
unf (>= 0.0.5, < 1.0.0)
http-cookie (1.0.2)
domain_name (~> 0.5)
json (1.8.3)
json_expressions (0.8.3)
mime-types (2.99)
netrc (0.11.0)
parser (2.2.0.pre.7)
ast (>= 1.1, < 3.0)
slop (~> 3.4, >= 3.4.5)
powerpack (0.0.9)
rainbow (2.0.0)
rake (10.3.2)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.7)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
coveralls_reborn (0.16.0)
simplecov (~> 0.18.1)
term-ansicolor (~> 1.6)
thor (>= 0.20.3, < 2.0)
tins (~> 1.16)
diff-lcs (1.3)
docile (1.3.2)
json_expressions (0.9.0)
rake (13.0.1)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
rubocop (0.27.1)
astrolabe (~> 1.3)
parser (>= 2.2.0.pre.7, < 3.0)
powerpack (~> 0.0.6)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.0)
simplecov (0.11.1)
docile (~> 1.1.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
term-ansicolor (1.3.2)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
simplecov (0.18.5)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
sync (0.5.0)
term-ansicolor (1.7.1)
tins (~> 1.0)
thor (0.19.1)
tins (1.6.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
thor (1.0.1)
tins (1.25.0)
sync

PLATFORMS
ruby

DEPENDENCIES
coveralls (~> 0.8.10)
json_expressions (~> 0.8.3)
rake (~> 10.3)
rspec (~> 3.1)
rubocop (~> 0.27.1)
simplecov (~> 0.11.1)
coveralls_reborn
json_expressions
rake
rspec
simplecov
u2f!

BUNDLED WITH
1.11.0
2.1.4
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Ruby U2F

[![Gem Version](https://badge.fury.io/rb/u2f.png)](http://badge.fury.io/rb/u2f)
[![Dependency Status](https://gemnasium.com/castle/ruby-u2f.svg)](https://gemnasium.com/castle/ruby-u2f)
[![Gem Version](https://badge.fury.io/rb/u2f.svg)](https://badge.fury.io/rb/u2f)
[![security](https://hakiri.io/github/castle/ruby-u2f/master.svg)](https://hakiri.io/github/castle/ruby-u2f/master)

[![Build Status](https://travis-ci.org/castle/ruby-u2f.png)](https://travis-ci.org/castle/ruby-u2f)
[![Build Status](https://travis-ci.org/castle/ruby-u2f.svg?branch=API_v1_1)](https://travis-ci.org/castle/ruby-u2f)
[![Code Climate](https://codeclimate.com/github/castle/ruby-u2f/badges/gpa.svg)](https://codeclimate.com/github/castle/ruby-u2f)
[![Coverage Status](https://img.shields.io/coveralls/castle/ruby-u2f.svg)](https://coveralls.io/r/castle/ruby-u2f)

Expand Down Expand Up @@ -40,7 +39,9 @@ The U2F library has two major tasks:

Each task starts by generating a challenge on the server, which is rendered to a web view, read by the browser APIs and transmitted to the plugged in U2F devices for verification. The U2F device responds and triggers a callback in the browser, and a form is posted back to your server where you verify the challenge and store the U2F device information to your database.

You'll need an instance of `U2F::U2F`, which is conveniently placed in an [instance method](https://github.com/castle/ruby-u2f/blob/master/example/app/helpers/helpers.rb) on the controller. The initializer takes an **App ID** as argument.
Note that ordinarily, each user will have one or more U2F registrations (as it's a common usage pattern for users to have more than one U2F device -- for example one for regular use, and a second stored safely as a backup). While it's omitted from examples here for brevity, a new registration should typically be associated with the particular user registering. Likewise, when authenticating, queries over "all registrations" should actually be scoped to registrations associated with the particular user being authenticated.

You'll need an instance of `U2F::U2F`, which is conveniently placed in an [instance method](https://github.com/castle/ruby-u2f/blob/API_v1_1/example/app/helpers/helpers.rb) on the controller. The initializer takes an **App ID** as argument.

```ruby
def u2f
Expand All @@ -67,6 +68,8 @@ def new
key_handles = Registration.map(&:key_handle)
@sign_requests = u2f.authentication_requests(key_handles)

@app_id = u2f.app_id

render 'registrations/new'
end
```
Expand All @@ -82,10 +85,11 @@ Render a form that will be automatically posted when the U2F device reponds.

```javascript
// render requests from server into Javascript format
var registerRequests = <%= @registration_requests.as_json.to_json.html_safe %>;
var appId = <%= @app_id.to_json.html_safe %>
var registerRequests = <%= @registration_requests.to_json.html_safe %>;
var signRequests = <%= @sign_requests.as_json.to_json.html_safe %>;

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

if (registerResponse.errorCode) {
Expand Down Expand Up @@ -138,10 +142,12 @@ def new
return 'Need to register first' if key_handles.empty?

# Generate SignRequests
@app_id = u2f.app_id
@sign_requests = u2f.authentication_requests(key_handles)
@challenge = u2f.challenge

# Store challenges. We need them for the verification step
session[:challenges] = @sign_requests.map(&:challenge)
# Store challenge. We need it for the verification step
session[:challenge] = @challenge

render 'authentications/new'
end
Expand All @@ -158,9 +164,11 @@ Render a form that will be automatically posted when the U2F device reponds.

```javascript
// render requests from server into Javascript format
var signRequests = <%= @sign_requests.as_json.to_json.html_safe %>;
var signRequests = <%= @sign_requests.to_json.html_safe %>;
var challenge = <%= @challenge.to_json.html_safe %>;
var appId = <%= @app_id.to_json.html_safe %>;

u2f.sign(signRequests, function(signResponse) {
u2f.sign(appId, challenge, signRequests, function(signResponse) {
var form, reg;

if (signResponse.errorCode) {
Expand All @@ -187,13 +195,13 @@ def create
return 'Need to register first' unless registration

begin
u2f.authenticate!(session[:challenges], response,
u2f.authenticate!(session[:challenge], response,
Base64.decode64(registration.public_key),
registration.counter)
rescue U2F::Error => e
return "Unable to authenticate: <%= e.class.name %>"
ensure
session.delete(:challenges)
session.delete(:challenge)
end

registration.update(counter: response.counter)
Expand Down
10 changes: 6 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new

task :default => :spec
task :test => :spec
task default: :spec
task test: :spec
21 changes: 13 additions & 8 deletions example/Gemfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Project requirements
gem 'rake'

# Component requirements
gem 'haml'
gem 'dm-aggregates'
gem 'dm-constraints'
gem 'dm-core'
gem 'dm-migrations'
gem 'dm-sqlite-adapter'
gem 'dm-validations'
gem 'dm-timestamps'
gem 'dm-migrations'
gem 'dm-constraints'
gem 'dm-aggregates'
gem 'dm-types'
gem 'dm-core'
gem 'dm-validations'
gem 'haml'

# Padrino Stable Gem
gem 'padrino', '0.12.4'
gem 'padrino'

# To enable https
gem 'thin'

gem 'u2f'#, path: '../.'
gem 'u2f', '1.0.0'
Loading