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.
- checksums.yaml +5 -5
- data/.circleci/config.yml +46 -0
- data/.gitignore +8 -0
- data/Gemfile +3 -22
- data/README.md +13 -14
- data/Rakefile +6 -28
- data/bin/rspec +10 -0
- data/bin/setup +12 -0
- data/{devise-2fa.gemspec → devise_2fa.gemspec} +15 -8
- data/lib/devise-2fa/version.rb +1 -1
- data/lib/devise_two_factorable/models/two_factorable.rb +5 -1
- data/{test → spec}/dummy/Rakefile +2 -3
- data/{test/dummy/app/mailers/.gitkeep → spec/dummy/app/assets/images/.keep} +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +3 -0
- data/{test/dummy/lib/assets/.gitkeep → spec/dummy/app/assets/javascripts/channels/.keep} +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/{test → spec}/dummy/app/controllers/application_controller.rb +4 -1
- data/{test/dummy/public/favicon.ico → spec/dummy/app/controllers/concerns/.keep} +0 -0
- data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/user.rb +6 -0
- data/spec/dummy/app/views/layouts/application.html.erb +19 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +25 -0
- data/spec/dummy/bin/update +25 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +14 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/{test → spec}/dummy/config/database.yml +10 -10
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +61 -0
- data/{test → spec}/dummy/config/environments/test.rb +15 -5
- data/spec/dummy/config/initializers/assets.rb +4 -0
- data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/{test → spec}/dummy/config/initializers/devise.rb +134 -56
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/{test → spec}/dummy/config/initializers/inflections.rb +6 -5
- data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -1
- data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +5 -5
- data/spec/dummy/config/locales/devise.en.yml +68 -0
- data/spec/dummy/config/locales/devise.two_factor.en.yml +57 -0
- data/spec/dummy/config/locales/en.yml +2 -0
- data/spec/dummy/config/puma.rb +9 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +8 -0
- data/spec/dummy/db/migrate/20190311184605_devise_create_users.rb +44 -0
- 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
- data/spec/dummy/db/schema.rb +39 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +1 -0
- data/spec/dummy/public/422.html +1 -0
- data/spec/dummy/public/500.html +19 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/models/user_spec.rb +33 -0
- data/spec/spec_helper.rb +69 -0
- data/spec/system/persistence_spec.rb +59 -0
- data/spec/system/refresh_spec.rb +100 -0
- data/spec/system/token_spec.rb +41 -0
- data/spec/system/users_spec.rb +98 -0
- metadata +213 -123
- data/.travis.yml +0 -28
- data/lib/devise_two_factorable/two_factorable.rb +0 -131
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/posts_controller.rb +0 -83
- data/test/dummy/app/helpers/posts_helper.rb +0 -2
- data/test/dummy/app/models/post.rb +0 -2
- data/test/dummy/app/models/user.rb +0 -20
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/posts/_form.html.erb +0 -25
- data/test/dummy/app/views/posts/edit.html.erb +0 -6
- data/test/dummy/app/views/posts/index.html.erb +0 -25
- data/test/dummy/app/views/posts/new.html.erb +0 -5
- data/test/dummy/app/views/posts/show.html.erb +0 -15
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -67
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -37
- data/test/dummy/config/environments/production.rb +0 -73
- data/test/dummy/config/initializers/secret_token.rb +0 -8
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -6
- data/test/dummy/db/migrate/20130125101430_create_users.rb +0 -9
- data/test/dummy/db/migrate/20130131092406_add_devise_to_users.rb +0 -52
- data/test/dummy/db/migrate/20130131142320_create_posts.rb +0 -10
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/script/rails +0 -6
- data/test/integration/persistence_test.rb +0 -63
- data/test/integration/refresh_test.rb +0 -103
- data/test/integration/sign_in_test.rb +0 -85
- data/test/integration/token_test.rb +0 -30
- data/test/integration_tests_helper.rb +0 -64
- data/test/model_tests_helper.rb +0 -20
- data/test/models/two_factorable_test.rb +0 -120
- data/test/orm/active_record.rb +0 -4
- data/test/orm/mongoid.rb +0 -13
- data/test/support/mongoid.yml +0 -6
- data/test/support/symmetric_encryption.yml +0 -70
- 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,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,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,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 %>
|
data/test/dummy/config.ru
DELETED
@@ -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
|
data/test/dummy/config/boot.rb
DELETED
@@ -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
|