devise-2fa 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +46 -0
  3. data/.gitignore +8 -0
  4. data/Gemfile +3 -22
  5. data/README.md +13 -14
  6. data/Rakefile +6 -28
  7. data/bin/rspec +10 -0
  8. data/bin/setup +12 -0
  9. data/{devise-2fa.gemspec → devise_2fa.gemspec} +15 -8
  10. data/lib/devise-2fa/version.rb +1 -1
  11. data/lib/devise_two_factorable/models/two_factorable.rb +5 -1
  12. data/{test → spec}/dummy/Rakefile +2 -3
  13. data/{test/dummy/app/mailers/.gitkeep → spec/dummy/app/assets/images/.keep} +0 -0
  14. data/spec/dummy/app/assets/javascripts/application.js +3 -0
  15. data/{test/dummy/lib/assets/.gitkeep → spec/dummy/app/assets/javascripts/channels/.keep} +0 -0
  16. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  17. data/{test → spec}/dummy/app/controllers/application_controller.rb +4 -1
  18. data/{test/dummy/public/favicon.ico → spec/dummy/app/controllers/concerns/.keep} +0 -0
  19. data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
  20. data/spec/dummy/app/models/application_record.rb +3 -0
  21. data/spec/dummy/app/models/concerns/.keep +0 -0
  22. data/spec/dummy/app/models/user.rb +6 -0
  23. data/spec/dummy/app/views/layouts/application.html.erb +19 -0
  24. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  25. data/spec/dummy/bin/bundle +3 -0
  26. data/spec/dummy/bin/rails +4 -0
  27. data/spec/dummy/bin/rake +4 -0
  28. data/spec/dummy/bin/setup +25 -0
  29. data/spec/dummy/bin/update +25 -0
  30. data/spec/dummy/bin/yarn +11 -0
  31. data/spec/dummy/config.ru +5 -0
  32. data/spec/dummy/config/application.rb +14 -0
  33. data/spec/dummy/config/boot.rb +5 -0
  34. data/{test → spec}/dummy/config/database.yml +10 -10
  35. data/spec/dummy/config/environment.rb +5 -0
  36. data/spec/dummy/config/environments/development.rb +61 -0
  37. data/{test → spec}/dummy/config/environments/test.rb +15 -5
  38. data/spec/dummy/config/initializers/assets.rb +4 -0
  39. data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  40. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  41. data/{test → spec}/dummy/config/initializers/devise.rb +134 -56
  42. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  43. data/{test → spec}/dummy/config/initializers/inflections.rb +6 -5
  44. data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -1
  45. data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +5 -5
  46. data/spec/dummy/config/locales/devise.en.yml +68 -0
  47. data/spec/dummy/config/locales/devise.two_factor.en.yml +57 -0
  48. data/spec/dummy/config/locales/en.yml +2 -0
  49. data/spec/dummy/config/puma.rb +9 -0
  50. data/spec/dummy/config/routes.rb +4 -0
  51. data/spec/dummy/config/spring.rb +6 -0
  52. data/spec/dummy/config/storage.yml +8 -0
  53. data/spec/dummy/db/migrate/20190311184605_devise_create_users.rb +44 -0
  54. data/{test/dummy/db/migrate/20130131160351_devise_otp_add_to_users.rb → spec/dummy/db/migrate/20190312222952_devise_two_factor_add_to_users.rb} +4 -5
  55. data/spec/dummy/db/schema.rb +39 -0
  56. data/spec/dummy/lib/assets/.keep +0 -0
  57. data/spec/dummy/package.json +5 -0
  58. data/spec/dummy/public/404.html +1 -0
  59. data/spec/dummy/public/422.html +1 -0
  60. data/spec/dummy/public/500.html +19 -0
  61. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  62. data/spec/dummy/public/apple-touch-icon.png +0 -0
  63. data/spec/dummy/public/favicon.ico +0 -0
  64. data/spec/dummy/storage/.keep +0 -0
  65. data/spec/models/user_spec.rb +33 -0
  66. data/spec/spec_helper.rb +69 -0
  67. data/spec/system/persistence_spec.rb +59 -0
  68. data/spec/system/refresh_spec.rb +100 -0
  69. data/spec/system/token_spec.rb +41 -0
  70. data/spec/system/users_spec.rb +98 -0
  71. metadata +213 -123
  72. data/.travis.yml +0 -28
  73. data/lib/devise_two_factorable/two_factorable.rb +0 -131
  74. data/test/dummy/README.rdoc +0 -261
  75. data/test/dummy/app/assets/javascripts/application.js +0 -13
  76. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  77. data/test/dummy/app/controllers/posts_controller.rb +0 -83
  78. data/test/dummy/app/helpers/posts_helper.rb +0 -2
  79. data/test/dummy/app/models/post.rb +0 -2
  80. data/test/dummy/app/models/user.rb +0 -20
  81. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  82. data/test/dummy/app/views/posts/_form.html.erb +0 -25
  83. data/test/dummy/app/views/posts/edit.html.erb +0 -6
  84. data/test/dummy/app/views/posts/index.html.erb +0 -25
  85. data/test/dummy/app/views/posts/new.html.erb +0 -5
  86. data/test/dummy/app/views/posts/show.html.erb +0 -15
  87. data/test/dummy/config.ru +0 -4
  88. data/test/dummy/config/application.rb +0 -67
  89. data/test/dummy/config/boot.rb +0 -10
  90. data/test/dummy/config/environment.rb +0 -5
  91. data/test/dummy/config/environments/development.rb +0 -37
  92. data/test/dummy/config/environments/production.rb +0 -73
  93. data/test/dummy/config/initializers/secret_token.rb +0 -8
  94. data/test/dummy/config/initializers/session_store.rb +0 -8
  95. data/test/dummy/config/locales/en.yml +0 -5
  96. data/test/dummy/config/routes.rb +0 -6
  97. data/test/dummy/db/migrate/20130125101430_create_users.rb +0 -9
  98. data/test/dummy/db/migrate/20130131092406_add_devise_to_users.rb +0 -52
  99. data/test/dummy/db/migrate/20130131142320_create_posts.rb +0 -10
  100. data/test/dummy/public/404.html +0 -26
  101. data/test/dummy/public/422.html +0 -26
  102. data/test/dummy/public/500.html +0 -25
  103. data/test/dummy/script/rails +0 -6
  104. data/test/integration/persistence_test.rb +0 -63
  105. data/test/integration/refresh_test.rb +0 -103
  106. data/test/integration/sign_in_test.rb +0 -85
  107. data/test/integration/token_test.rb +0 -30
  108. data/test/integration_tests_helper.rb +0 -64
  109. data/test/model_tests_helper.rb +0 -20
  110. data/test/models/two_factorable_test.rb +0 -120
  111. data/test/orm/active_record.rb +0 -4
  112. data/test/orm/mongoid.rb +0 -13
  113. data/test/support/mongoid.yml +0 -6
  114. data/test/support/symmetric_encryption.yml +0 -70
  115. data/test/test_helper.rb +0 -18
@@ -1,83 +0,0 @@
1
- class PostsController < ApplicationController
2
- # GET /posts
3
- # GET /posts.json
4
- def index
5
- @posts = Post.all
6
-
7
- respond_to do |format|
8
- format.html # index.html.erb
9
- format.json { render json: @posts }
10
- end
11
- end
12
-
13
- # GET /posts/1
14
- # GET /posts/1.json
15
- def show
16
- @post = Post.find(params[:id])
17
-
18
- respond_to do |format|
19
- format.html # show.html.erb
20
- format.json { render json: @post }
21
- end
22
- end
23
-
24
- # GET /posts/new
25
- # GET /posts/new.json
26
- def new
27
- @post = Post.new
28
-
29
- respond_to do |format|
30
- format.html # new.html.erb
31
- format.json { render json: @post }
32
- end
33
- end
34
-
35
- # GET /posts/1/edit
36
- def edit
37
- @post = Post.find(params[:id])
38
- end
39
-
40
- # POST /posts
41
- # POST /posts.json
42
- def create
43
- @post = Post.new(params[:post])
44
-
45
- respond_to do |format|
46
- if @post.save
47
- format.html { redirect_to @post, notice: 'Post was successfully created.' }
48
- format.json { render json: @post, status: :created, location: @post }
49
- else
50
- format.html { render action: 'new' }
51
- format.json { render json: @post.errors, status: :unprocessable_entity }
52
- end
53
- end
54
- end
55
-
56
- # PUT /posts/1
57
- # PUT /posts/1.json
58
- def update
59
- @post = Post.find(params[:id])
60
-
61
- respond_to do |format|
62
- if @post.update_attributes(params[:post])
63
- format.html { redirect_to @post, notice: 'Post was successfully updated.' }
64
- format.json { head :ok }
65
- else
66
- format.html { render action: 'edit' }
67
- format.json { render json: @post.errors, status: :unprocessable_entity }
68
- end
69
- end
70
- end
71
-
72
- # DELETE /posts/1
73
- # DELETE /posts/1.json
74
- def destroy
75
- @post = Post.find(params[:id])
76
- @post.destroy
77
-
78
- respond_to do |format|
79
- format.html { redirect_to posts_url }
80
- format.json { head :ok }
81
- end
82
- end
83
- end
@@ -1,2 +0,0 @@
1
- module PostsHelper
2
- end
@@ -1,2 +0,0 @@
1
- class Post < PARENT_MODEL_CLASS
2
- end
@@ -1,20 +0,0 @@
1
- class User < PARENT_MODEL_CLASS
2
- if DEVISE_ORM == :mongoid
3
- include Mongoid::Document
4
-
5
- ## Database authenticatable
6
- field :email, type: String, null: false, default: ''
7
- field :encrypted_password, type: String, null: false, default: ''
8
-
9
- ## Recoverable
10
- field :reset_password_token, type: String
11
- field :reset_password_sent_at, type: Time
12
- end
13
-
14
- devise :two_factorable, :database_authenticatable, :registerable,
15
- :trackable, :validatable
16
-
17
- # Setup accessible (or protected) attributes for your model
18
- # attr_accessible :otp_enabled, :otp_mandatory, :as => :otp_privileged
19
- # attr_accessible :email, :password, :password_confirmation, :remember_me
20
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", :media => "all" %>
6
- <%= javascript_include_tag "application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,25 +0,0 @@
1
- <%= form_for(@post) do |f| %>
2
- <% if @post.errors.any? %>
3
- <div id="error_explanation">
4
- <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
5
-
6
- <ul>
7
- <% @post.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <div class="field">
15
- <%= f.label :title %><br />
16
- <%= f.text_field :title %>
17
- </div>
18
- <div class="field">
19
- <%= f.label :body %><br />
20
- <%= f.text_area :body %>
21
- </div>
22
- <div class="actions">
23
- <%= f.submit %>
24
- </div>
25
- <% end %>
@@ -1,6 +0,0 @@
1
- <h1>Editing post</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Show', @post %> |
6
- <%= link_to 'Back', posts_path %>
@@ -1,25 +0,0 @@
1
- <h1>Listing posts</h1>
2
-
3
- <table>
4
- <tr>
5
- <th>Title</th>
6
- <th>Body</th>
7
- <th></th>
8
- <th></th>
9
- <th></th>
10
- </tr>
11
-
12
- <% @posts.each do |post| %>
13
- <tr>
14
- <td><%= post.title %></td>
15
- <td><%= post.body %></td>
16
- <td><%= link_to 'Show', post %></td>
17
- <td><%= link_to 'Edit', edit_post_path(post) %></td>
18
- <td><%= link_to 'Destroy', post, confirm: 'Are you sure?', method: :delete %></td>
19
- </tr>
20
- <% end %>
21
- </table>
22
-
23
- <br />
24
-
25
- <%= link_to 'New Post', new_post_path %>
@@ -1,5 +0,0 @@
1
- <h1>New post</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Back', posts_path %>
@@ -1,15 +0,0 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <p>
4
- <b>Title:</b>
5
- <%= @post.title %>
6
- </p>
7
-
8
- <p>
9
- <b>Body:</b>
10
- <%= @post.body %>
11
- </p>
12
-
13
-
14
- <%= link_to 'Edit', edit_post_path(@post) %> |
15
- <%= link_to 'Back', posts_path %>
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Dummy::Application
@@ -1,67 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- # Pick the frameworks you want:
4
- require 'active_record/railtie'
5
- require 'action_controller/railtie'
6
- require 'action_mailer/railtie'
7
- # require "active_resource/railtie"
8
- require 'sprockets/railtie'
9
- # require "rails/test_unit/railtie"
10
-
11
- Bundler.require
12
- Bundler.require(:default, DEVISE_ORM) if defined?(Bundler)
13
-
14
- begin
15
- require "#{DEVISE_ORM}/railtie"
16
- rescue LoadError
17
- end
18
- PARENT_MODEL_CLASS = DEVISE_ORM == :active_record ? ActiveRecord::Base : Object
19
-
20
- require 'devise'
21
- require 'devise-2fa'
22
-
23
- module Dummy
24
- class Application < Rails::Application
25
- # Settings in config/environments/* take precedence over those specified here.
26
- # Application configuration should go into files in config/initializers
27
- # -- all .rb files in that directory are automatically loaded.
28
-
29
- # Custom directories with classes and modules you want to be autoloadable.
30
- # config.autoload_paths += %W(#{config.root}/extras)
31
-
32
- # Only load the plugins named here, in the order given (default is alphabetical).
33
- # :all can be used as a placeholder for all plugins not explicitly named.
34
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
35
-
36
- # Activate observers that should always be running.
37
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
38
-
39
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
40
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
41
- # config.time_zone = 'Central Time (US & Canada)'
42
-
43
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
44
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
45
- # config.i18n.default_locale = :de
46
-
47
- # Configure the default encoding used in templates for Ruby 1.9.
48
- config.encoding = 'utf-8'
49
-
50
- # Configure sensitive parameters which will be filtered from the log file.
51
- config.filter_parameters += [:password]
52
-
53
- # Enable escaping HTML in JSON.
54
- config.active_support.escape_html_entities_in_json = true
55
-
56
- # Use SQL instead of Active Record's schema dumper when creating the database.
57
- # This is necessary if your schema can't be completely dumped by the schema dumper,
58
- # like if you have constraints or database-specific column types
59
- # config.active_record.schema_format = :sql
60
-
61
- # Enable the asset pipeline
62
- config.assets.enabled = true
63
-
64
- # Version of your assets, change this if you want to expire all your assets
65
- config.assets.version = '1.0'
66
- end
67
- end
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- if File.exist?(gemfile)
5
- ENV['BUNDLE_GEMFILE'] = gemfile
6
- require 'bundler'
7
- Bundler.setup
8
- end
9
-
10
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- Dummy::Application.initialize!
@@ -1,37 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Do not eager load code on boot.
10
- config.eager_load = false
11
-
12
- # Show full error reports and disable caching
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger
20
- config.active_support.deprecation = :log
21
-
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
24
-
25
- # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
27
-
28
- # Log the query plan for queries taking more than this (works
29
- # with SQLite, MySQL, and PostgreSQL)
30
- config.active_record.auto_explain_threshold_in_seconds = 0.5
31
-
32
- # Do not compress assets
33
- config.assets.compress = false
34
-
35
- # Expands the lines which load the assets
36
- config.assets.debug = true
37
- end
@@ -1,73 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # Code is not reloaded between requests
5
- config.cache_classes = true
6
-
7
- # Eager load code on boot. This eager loads most of Rails and
8
- # your application in memory, allowing both thread web servers
9
- # and those relying on copy on write to perform better.
10
- # Rake tasks automatically ignore this option for performance.
11
- config.eager_load = true
12
-
13
- # Full error reports are disabled and caching is turned on
14
- config.consider_all_requests_local = false
15
- config.action_controller.perform_caching = true
16
-
17
- # Disable Rails's static asset server (Apache or nginx will already do this)
18
- config.serve_static_assets = false
19
-
20
- # Compress JavaScripts and CSS
21
- config.assets.compress = true
22
-
23
- # Don't fallback to assets pipeline if a precompiled asset is missed
24
- config.assets.compile = false
25
-
26
- # Generate digests for assets URLs
27
- config.assets.digest = true
28
-
29
- # Defaults to nil and saved in location specified by config.assets.prefix
30
- # config.assets.manifest = YOUR_PATH
31
-
32
- # Specifies the header that your server uses for sending files
33
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
34
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
35
-
36
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
37
- # config.force_ssl = true
38
-
39
- # See everything in the log (default is :info)
40
- # config.log_level = :debug
41
-
42
- # Prepend all log lines with the following tags
43
- # config.log_tags = [ :subdomain, :uuid ]
44
-
45
- # Use a different logger for distributed setups
46
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
47
-
48
- # Use a different cache store in production
49
- # config.cache_store = :mem_cache_store
50
-
51
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
52
- # config.action_controller.asset_host = "http://assets.example.com"
53
-
54
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
55
- # config.assets.precompile += %w( search.js )
56
-
57
- # Disable delivery errors, bad email addresses will be ignored
58
- # config.action_mailer.raise_delivery_errors = false
59
-
60
- # Enable threaded mode
61
- # config.threadsafe!
62
-
63
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
64
- # the I18n.default_locale when a translation can not be found)
65
- config.i18n.fallbacks = true
66
-
67
- # Send deprecation notices to registered listeners
68
- config.active_support.deprecation = :notify
69
-
70
- # Log the query plan for queries taking more than this (works
71
- # with SQLite, MySQL, and PostgreSQL)
72
- # config.active_record.auto_explain_threshold_in_seconds = 0.5
73
- end
@@ -1,8 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = '7854ba4c663086c191afbc2e05384503b5529fa2c8e51417539db1cbe7c68e8490e9d57a1d908d4e82816a522edb97f71a8de9233272a5598534a38ef1b08697'
8
- Dummy::Application.config.secret_key_base = '7854ba4c663086c191afbc2e05384503b5529fa2c8e51417539db1cbe7c68e8490e9d57a1d908d4e82816a522edb97f71a8de9233272a5598534a38ef1b08697'
@@ -1,8 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
-
5
- # Use the database for sessions instead of the cookie-based default,
6
- # which shouldn't be used to store highly confidential information
7
- # (create the session table with "rails generate session_migration")
8
- # Dummy::Application.config.session_store :active_record_store
@@ -1,5 +0,0 @@
1
- # Sample localization file for English. Add more files in this directory for other locales.
2
- # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
-
4
- en:
5
- hello: "Hello world"
@@ -1,6 +0,0 @@
1
- Dummy::Application.routes.draw do
2
- devise_for :users
3
-
4
- resources :posts
5
- root to: 'posts#index'
6
- end