defra_ruby_features 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +8 -0
- data/README.md +92 -0
- data/Rakefile +40 -0
- data/app/controllers/defra_ruby_features/application_controller.rb +7 -0
- data/app/controllers/defra_ruby_features/feature_toggles_controller.rb +58 -0
- data/app/helpers/defra_ruby_features/application_helper.rb +6 -0
- data/app/helpers/delete_link_helper.rb +16 -0
- data/app/views/defra_ruby_features/feature_toggles/index.html.erb +48 -0
- data/app/views/defra_ruby_features/feature_toggles/new.html.erb +35 -0
- data/app/views/shared/_back.html.erb +1 -0
- data/config/locales/defra_ruby_features.en.yml +24 -0
- data/config/routes.rb +5 -0
- data/lib/defra_ruby_features.rb +26 -0
- data/lib/defra_ruby_features/configuration.rb +7 -0
- data/lib/defra_ruby_features/engine.rb +13 -0
- data/lib/defra_ruby_features/version.rb +5 -0
- data/lib/tasks/changelog.rake +8 -0
- data/spec/dummy/Rakefile +8 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +6 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +6 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/controllers/test_controller.rb +7 -0
- data/spec/dummy/app/helpers/application_helper.rb +4 -0
- data/spec/dummy/app/javascript/packs/application.js +14 -0
- data/spec/dummy/app/jobs/application_job.rb +9 -0
- data/spec/dummy/app/models/ability.rb +9 -0
- data/spec/dummy/app/models/application_record.rb +5 -0
- data/spec/dummy/app/models/feature_toggle.rb +4 -0
- data/spec/dummy/app/models/user.rb +8 -0
- data/spec/dummy/app/views/layouts/application.html.erb +12 -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/config.ru +7 -0
- data/spec/dummy/config/application.rb +29 -0
- data/spec/dummy/config/boot.rb +7 -0
- data/spec/dummy/config/database.yml +21 -0
- data/spec/dummy/config/environment.rb +7 -0
- data/spec/dummy/config/environments/development.rb +50 -0
- data/spec/dummy/config/environments/test.rb +41 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +10 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +9 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +30 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
- data/spec/dummy/config/initializers/defra_ruby_features.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +311 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy/config/initializers/inflections.rb +18 -0
- data/spec/dummy/config/initializers/mime_types.rb +6 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +11 -0
- data/spec/dummy/config/locales/devise.en.yml +65 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/routes.rb +7 -0
- data/spec/dummy/db/migrate/20200623125321_create_feature_toggles.rb +12 -0
- data/spec/dummy/db/migrate/20200624115316_devise_create_users.rb +44 -0
- data/spec/dummy/db/schema.rb +34 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +4579 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -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/tmp/development_secret.txt +1 -0
- data/spec/examples.txt +13 -0
- data/spec/factories/feature_toggle.rb +8 -0
- data/spec/factories/user.rb +11 -0
- data/spec/lib/defra_ruby_mocks/configuration_spec.rb +13 -0
- data/spec/rails_helper.rb +54 -0
- data/spec/requests/defra_ruby_features/feature_toggles_spec.rb +145 -0
- data/spec/spec_helper.rb +83 -0
- data/spec/support/database_cleaner.rb +19 -0
- data/spec/support/devise.rb +5 -0
- data/spec/support/factory_bot.rb +8 -0
- data/spec/support/migrations.rb +10 -0
- data/spec/support/pry.rb +7 -0
- data/spec/support/rails_controller_testing.rb +5 -0
- data/spec/support/simplecov.rb +17 -0
- metadata +364 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require rails-ujs
|
14
|
+
//= require_tree .
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ApplicationJob < ActiveJob::Base
|
4
|
+
# Automatically retry jobs that encountered a deadlock
|
5
|
+
# retry_on ActiveRecord::Deadlocked
|
6
|
+
|
7
|
+
# Most jobs are safe to ignore if the underlying records are no longer available
|
8
|
+
# discard_on ActiveJob::DeserializationError
|
9
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class User < ApplicationRecord
|
4
|
+
# Include default devise modules. Others available are:
|
5
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
6
|
+
devise :database_authenticatable, :registerable,
|
7
|
+
:recoverable, :rememberable, :validatable
|
8
|
+
end
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
6
|
+
|
7
|
+
def system!(*args)
|
8
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
9
|
+
end
|
10
|
+
|
11
|
+
FileUtils.chdir APP_ROOT do
|
12
|
+
# This script is a way to setup or update your development environment automatically.
|
13
|
+
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
|
14
|
+
# Add necessary setup steps to this file.
|
15
|
+
|
16
|
+
puts "== Installing dependencies =="
|
17
|
+
system! "gem install bundler --conservative"
|
18
|
+
system("bundle check") || system!("bundle install")
|
19
|
+
|
20
|
+
puts "\n== Removing old logs and tempfiles =="
|
21
|
+
system! "bin/rails log:clear tmp:clear"
|
22
|
+
|
23
|
+
puts "\n== Restarting application server =="
|
24
|
+
system! "bin/rails restart"
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "boot"
|
4
|
+
|
5
|
+
require "rails"
|
6
|
+
# Pick the frameworks you want:
|
7
|
+
require "active_model/railtie"
|
8
|
+
require "active_record/railtie"
|
9
|
+
require "action_controller/railtie"
|
10
|
+
require "action_view/railtie"
|
11
|
+
require "sprockets/railtie"
|
12
|
+
require "devise"
|
13
|
+
require "cancancan"
|
14
|
+
|
15
|
+
Bundler.require(*Rails.groups)
|
16
|
+
require "defra_ruby_features"
|
17
|
+
|
18
|
+
module Dummy
|
19
|
+
class Application < Rails::Application
|
20
|
+
# Initialize configuration defaults for originally generated Rails version.
|
21
|
+
config.load_defaults 6.0
|
22
|
+
config.autoloader = :classic
|
23
|
+
|
24
|
+
# Settings in config/environments/* take precedence over those specified here.
|
25
|
+
# Application configuration can go into files in config/initializers
|
26
|
+
# -- all .rb files in that directory are automatically loaded after loading
|
27
|
+
# the framework and any gems in your application.
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Set up gems listed in the Gemfile.
|
4
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
|
5
|
+
|
6
|
+
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
|
7
|
+
$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
#
|
7
|
+
default: &default
|
8
|
+
adapter: sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
development:
|
13
|
+
<<: *default
|
14
|
+
database: db/development.sqlite3
|
15
|
+
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
17
|
+
# re-generated from your development database when you run "rake".
|
18
|
+
# Do not set this db to the same as development or production.
|
19
|
+
test:
|
20
|
+
<<: *default
|
21
|
+
database: db/test.sqlite3
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Rails.application.configure do
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
+
|
6
|
+
# In the development environment your application's code is reloaded on
|
7
|
+
# every request. This slows down response time but is perfect for development
|
8
|
+
# since you don't have to restart the web server when you make code changes.
|
9
|
+
config.cache_classes = false
|
10
|
+
|
11
|
+
# Do not eager load code on boot.
|
12
|
+
config.eager_load = false
|
13
|
+
|
14
|
+
# Show full error reports.
|
15
|
+
config.consider_all_requests_local = true
|
16
|
+
|
17
|
+
# Enable/disable caching. By default caching is disabled.
|
18
|
+
# Run rails dev:cache to toggle caching.
|
19
|
+
if Rails.root.join("tmp", "caching-dev.txt").exist?
|
20
|
+
config.action_controller.perform_caching = true
|
21
|
+
config.action_controller.enable_fragment_cache_logging = true
|
22
|
+
|
23
|
+
config.cache_store = :memory_store
|
24
|
+
config.public_file_server.headers = {
|
25
|
+
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
26
|
+
}
|
27
|
+
else
|
28
|
+
config.action_controller.perform_caching = false
|
29
|
+
|
30
|
+
config.cache_store = :null_store
|
31
|
+
end
|
32
|
+
|
33
|
+
# Print deprecation notices to the Rails logger.
|
34
|
+
config.active_support.deprecation = :log
|
35
|
+
|
36
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
37
|
+
# This option may cause significant delays in view rendering with a large
|
38
|
+
# number of complex assets.
|
39
|
+
config.assets.debug = true
|
40
|
+
|
41
|
+
# Suppress logger output for asset requests.
|
42
|
+
config.assets.quiet = true
|
43
|
+
|
44
|
+
# Raises error for missing translations.
|
45
|
+
# config.action_view.raise_on_missing_translations = true
|
46
|
+
|
47
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
48
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
49
|
+
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
50
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The test environment is used exclusively to run your application's
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
7
|
+
|
8
|
+
Rails.application.configure do
|
9
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
10
|
+
|
11
|
+
config.cache_classes = false
|
12
|
+
config.action_view.cache_template_loading = true
|
13
|
+
|
14
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
15
|
+
# just for the purpose of running a single test. If you are using a tool that
|
16
|
+
# preloads Rails for running tests, you may have to set it to true.
|
17
|
+
config.eager_load = false
|
18
|
+
|
19
|
+
# Configure public file server for tests with Cache-Control for performance.
|
20
|
+
config.public_file_server.enabled = true
|
21
|
+
config.public_file_server.headers = {
|
22
|
+
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
|
23
|
+
}
|
24
|
+
|
25
|
+
# Show full error reports and disable caching.
|
26
|
+
config.consider_all_requests_local = true
|
27
|
+
config.action_controller.perform_caching = false
|
28
|
+
config.cache_store = :null_store
|
29
|
+
|
30
|
+
# Raise exceptions instead of rendering exception templates.
|
31
|
+
config.action_dispatch.show_exceptions = false
|
32
|
+
|
33
|
+
# Disable request forgery protection in test environment.
|
34
|
+
config.action_controller.allow_forgery_protection = false
|
35
|
+
|
36
|
+
# Print deprecation notices to the stderr.
|
37
|
+
config.active_support.deprecation = :stderr
|
38
|
+
|
39
|
+
# Raises error for missing translations.
|
40
|
+
# config.action_view.raise_on_missing_translations = true
|
41
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Be sure to restart your server when you modify this file.
|
4
|
+
|
5
|
+
# Version of your assets, change this if you want to expire all your assets.
|
6
|
+
Rails.application.config.assets.version = "1.0"
|
7
|
+
|
8
|
+
# Add additional assets to the asset load path.
|
9
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
10
|
+
|
11
|
+
# Precompile additional assets.
|
12
|
+
# application.js, application.css, and all non-JS/CSS in the app/assets
|
13
|
+
# folder are already added.
|
14
|
+
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Be sure to restart your server when you modify this file.
|
4
|
+
|
5
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
6
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
7
|
+
|
8
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
9
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Be sure to restart your server when you modify this file.
|
4
|
+
|
5
|
+
# Define an application-wide content security policy
|
6
|
+
# For further information see the following documentation
|
7
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
8
|
+
|
9
|
+
# Rails.application.config.content_security_policy do |policy|
|
10
|
+
# policy.default_src :self, :https
|
11
|
+
# policy.font_src :self, :https, :data
|
12
|
+
# policy.img_src :self, :https, :data
|
13
|
+
# policy.object_src :none
|
14
|
+
# policy.script_src :self, :https
|
15
|
+
# policy.style_src :self, :https
|
16
|
+
|
17
|
+
# # Specify URI for violation reports
|
18
|
+
# # policy.report_uri "/csp-violation-report-endpoint"
|
19
|
+
# end
|
20
|
+
|
21
|
+
# If you are using UJS then enable automatic nonce generation
|
22
|
+
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
|
23
|
+
|
24
|
+
# Set the nonce only to specific directives
|
25
|
+
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
|
26
|
+
|
27
|
+
# Report CSP violations to a specified URI
|
28
|
+
# For further information see the following documentation:
|
29
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
|
30
|
+
# Rails.application.config.content_security_policy_report_only = true
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Be sure to restart your server when you modify this file.
|
4
|
+
|
5
|
+
# Specify a serializer for the signed and encrypted cookie jars.
|
6
|
+
# Valid options are :json, :marshal, and :hybrid.
|
7
|
+
Rails.application.config.action_dispatch.cookies_serializer = :json
|
@@ -0,0 +1,311 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Assuming you have not yet modified this file, each configuration option below
|
4
|
+
# is set to its default value. Note that some are commented out while others
|
5
|
+
# are not: uncommented lines are intended to protect your configuration from
|
6
|
+
# breaking changes in upgrades (i.e., in the event that future versions of
|
7
|
+
# Devise change the default values for those options).
|
8
|
+
#
|
9
|
+
# Use this hook to configure devise mailer, warden hooks and so forth.
|
10
|
+
# Many of these configuration options can be set straight in your model.
|
11
|
+
Devise.setup do |config|
|
12
|
+
# The secret key used by Devise. Devise uses this key to generate
|
13
|
+
# random tokens. Changing this key will render invalid all existing
|
14
|
+
# confirmation, reset password and unlock tokens in the database.
|
15
|
+
# Devise will use the `secret_key_base` as its `secret_key`
|
16
|
+
# by default. You can change it below and use your own secret key.
|
17
|
+
# config.secret_key = 'dummy'
|
18
|
+
|
19
|
+
# ==> Controller configuration
|
20
|
+
# Configure the parent class to the devise controllers.
|
21
|
+
# config.parent_controller = 'DeviseController'
|
22
|
+
|
23
|
+
# ==> Mailer Configuration
|
24
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
25
|
+
# note that it will be overwritten if you use your own mailer class
|
26
|
+
# with default "from" parameter.
|
27
|
+
config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
|
28
|
+
|
29
|
+
# Configure the class responsible to send e-mails.
|
30
|
+
# config.mailer = 'Devise::Mailer'
|
31
|
+
|
32
|
+
# Configure the parent class responsible to send e-mails.
|
33
|
+
# config.parent_mailer = 'ActionMailer::Base'
|
34
|
+
|
35
|
+
# ==> ORM configuration
|
36
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
37
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
38
|
+
# available as additional gems.
|
39
|
+
require "devise/orm/active_record"
|
40
|
+
|
41
|
+
# ==> Configuration for any authentication mechanism
|
42
|
+
# Configure which keys are used when authenticating a user. The default is
|
43
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
44
|
+
# authenticating a user, both parameters are required. Remember that those
|
45
|
+
# parameters are used only when authenticating and not when retrieving from
|
46
|
+
# session. If you need permissions, you should implement that in a before filter.
|
47
|
+
# You can also supply a hash where the value is a boolean determining whether
|
48
|
+
# or not authentication should be aborted when the value is not present.
|
49
|
+
# config.authentication_keys = [:email]
|
50
|
+
|
51
|
+
# Configure parameters from the request object used for authentication. Each entry
|
52
|
+
# given should be a request method and it will automatically be passed to the
|
53
|
+
# find_for_authentication method and considered in your model lookup. For instance,
|
54
|
+
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
55
|
+
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
56
|
+
# config.request_keys = []
|
57
|
+
|
58
|
+
# Configure which authentication keys should be case-insensitive.
|
59
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
60
|
+
# to authenticate or find a user. Default is :email.
|
61
|
+
config.case_insensitive_keys = [:email]
|
62
|
+
|
63
|
+
# Configure which authentication keys should have whitespace stripped.
|
64
|
+
# These keys will have whitespace before and after removed upon creating or
|
65
|
+
# modifying a user and when used to authenticate or find a user. Default is :email.
|
66
|
+
config.strip_whitespace_keys = [:email]
|
67
|
+
|
68
|
+
# Tell if authentication through request.params is enabled. True by default.
|
69
|
+
# It can be set to an array that will enable params authentication only for the
|
70
|
+
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
71
|
+
# enable it only for database (email + password) authentication.
|
72
|
+
# config.params_authenticatable = true
|
73
|
+
|
74
|
+
# Tell if authentication through HTTP Auth is enabled. False by default.
|
75
|
+
# It can be set to an array that will enable http authentication only for the
|
76
|
+
# given strategies, for example, `config.http_authenticatable = [:database]` will
|
77
|
+
# enable it only for database authentication.
|
78
|
+
# For API-only applications to support authentication "out-of-the-box", you will likely want to
|
79
|
+
# enable this with :database unless you are using a custom strategy.
|
80
|
+
# The supported strategies are:
|
81
|
+
# :database = Support basic authentication with authentication key + password
|
82
|
+
# config.http_authenticatable = false
|
83
|
+
|
84
|
+
# If 401 status code should be returned for AJAX requests. True by default.
|
85
|
+
# config.http_authenticatable_on_xhr = true
|
86
|
+
|
87
|
+
# The realm used in Http Basic Authentication. 'Application' by default.
|
88
|
+
# config.http_authentication_realm = 'Application'
|
89
|
+
|
90
|
+
# It will change confirmation, password recovery and other workflows
|
91
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
92
|
+
# Does not affect registerable.
|
93
|
+
# config.paranoid = true
|
94
|
+
|
95
|
+
# By default Devise will store the user in session. You can skip storage for
|
96
|
+
# particular strategies by setting this option.
|
97
|
+
# Notice that if you are skipping storage for all authentication paths, you
|
98
|
+
# may want to disable generating routes to Devise's sessions controller by
|
99
|
+
# passing skip: :sessions to `devise_for` in your config/routes.rb
|
100
|
+
config.skip_session_storage = [:http_auth]
|
101
|
+
|
102
|
+
# By default, Devise cleans up the CSRF token on authentication to
|
103
|
+
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
104
|
+
# requests for sign in and sign up, you need to get a new CSRF token
|
105
|
+
# from the server. You can disable this option at your own risk.
|
106
|
+
# config.clean_up_csrf_token_on_authentication = true
|
107
|
+
|
108
|
+
# When false, Devise will not attempt to reload routes on eager load.
|
109
|
+
# This can reduce the time taken to boot the app but if your application
|
110
|
+
# requires the Devise mappings to be loaded during boot time the application
|
111
|
+
# won't boot properly.
|
112
|
+
# config.reload_routes = true
|
113
|
+
|
114
|
+
# ==> Configuration for :database_authenticatable
|
115
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 12. If
|
116
|
+
# using other algorithms, it sets how many times you want the password to be hashed.
|
117
|
+
# The number of stretches used for generating the hashed password are stored
|
118
|
+
# with the hashed password. This allows you to change the stretches without
|
119
|
+
# invalidating existing passwords.
|
120
|
+
#
|
121
|
+
# Limiting the stretches to just one in testing will increase the performance of
|
122
|
+
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
123
|
+
# a value less than 10 in other environments. Note that, for bcrypt (the default
|
124
|
+
# algorithm), the cost increases exponentially with the number of stretches (e.g.
|
125
|
+
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
|
126
|
+
config.stretches = Rails.env.test? ? 1 : 12
|
127
|
+
|
128
|
+
# Set up a pepper to generate the hashed password.
|
129
|
+
# config.pepper = 'dummy'
|
130
|
+
|
131
|
+
# Send a notification to the original email when the user's email is changed.
|
132
|
+
# config.send_email_changed_notification = false
|
133
|
+
|
134
|
+
# Send a notification email when the user's password is changed.
|
135
|
+
# config.send_password_change_notification = false
|
136
|
+
|
137
|
+
# ==> Configuration for :confirmable
|
138
|
+
# A period that the user is allowed to access the website even without
|
139
|
+
# confirming their account. For instance, if set to 2.days, the user will be
|
140
|
+
# able to access the website for two days without confirming their account,
|
141
|
+
# access will be blocked just in the third day.
|
142
|
+
# You can also set it to nil, which will allow the user to access the website
|
143
|
+
# without confirming their account.
|
144
|
+
# Default is 0.days, meaning the user cannot access the website without
|
145
|
+
# confirming their account.
|
146
|
+
# config.allow_unconfirmed_access_for = 2.days
|
147
|
+
|
148
|
+
# A period that the user is allowed to confirm their account before their
|
149
|
+
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
150
|
+
# their account within 3 days after the mail was sent, but on the fourth day
|
151
|
+
# their account can't be confirmed with the token any more.
|
152
|
+
# Default is nil, meaning there is no restriction on how long a user can take
|
153
|
+
# before confirming their account.
|
154
|
+
# config.confirm_within = 3.days
|
155
|
+
|
156
|
+
# If true, requires any email changes to be confirmed (exactly the same way as
|
157
|
+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
158
|
+
# db field (see migrations). Until confirmed, new email is stored in
|
159
|
+
# unconfirmed_email column, and copied to email column on successful confirmation.
|
160
|
+
config.reconfirmable = true
|
161
|
+
|
162
|
+
# Defines which key will be used when confirming an account
|
163
|
+
# config.confirmation_keys = [:email]
|
164
|
+
|
165
|
+
# ==> Configuration for :rememberable
|
166
|
+
# The time the user will be remembered without asking for credentials again.
|
167
|
+
# config.remember_for = 2.weeks
|
168
|
+
|
169
|
+
# Invalidates all the remember me tokens when the user signs out.
|
170
|
+
config.expire_all_remember_me_on_sign_out = true
|
171
|
+
|
172
|
+
# If true, extends the user's remember period when remembered via cookie.
|
173
|
+
# config.extend_remember_period = false
|
174
|
+
|
175
|
+
# Options to be passed to the created cookie. For instance, you can set
|
176
|
+
# secure: true in order to force SSL only cookies.
|
177
|
+
# config.rememberable_options = {}
|
178
|
+
|
179
|
+
# ==> Configuration for :validatable
|
180
|
+
# Range for password length.
|
181
|
+
config.password_length = 6..128
|
182
|
+
|
183
|
+
# Email regex used to validate email formats. It simply asserts that
|
184
|
+
# one (and only one) @ exists in the given string. This is mainly
|
185
|
+
# to give user feedback and not to assert the e-mail validity.
|
186
|
+
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
|
187
|
+
|
188
|
+
# ==> Configuration for :timeoutable
|
189
|
+
# The time you want to timeout the user session without activity. After this
|
190
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
191
|
+
# config.timeout_in = 30.minutes
|
192
|
+
|
193
|
+
# ==> Configuration for :lockable
|
194
|
+
# Defines which strategy will be used to lock an account.
|
195
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
196
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
197
|
+
# config.lock_strategy = :failed_attempts
|
198
|
+
|
199
|
+
# Defines which key will be used when locking and unlocking an account
|
200
|
+
# config.unlock_keys = [:email]
|
201
|
+
|
202
|
+
# Defines which strategy will be used to unlock an account.
|
203
|
+
# :email = Sends an unlock link to the user email
|
204
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
205
|
+
# :both = Enables both strategies
|
206
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
207
|
+
# config.unlock_strategy = :both
|
208
|
+
|
209
|
+
# Number of authentication tries before locking an account if lock_strategy
|
210
|
+
# is failed attempts.
|
211
|
+
# config.maximum_attempts = 20
|
212
|
+
|
213
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
214
|
+
# config.unlock_in = 1.hour
|
215
|
+
|
216
|
+
# Warn on the last attempt before the account is locked.
|
217
|
+
# config.last_attempt_warning = true
|
218
|
+
|
219
|
+
# ==> Configuration for :recoverable
|
220
|
+
#
|
221
|
+
# Defines which key will be used when recovering the password for an account
|
222
|
+
# config.reset_password_keys = [:email]
|
223
|
+
|
224
|
+
# Time interval you can reset your password with a reset password key.
|
225
|
+
# Don't put a too small interval or your users won't have the time to
|
226
|
+
# change their passwords.
|
227
|
+
config.reset_password_within = 6.hours
|
228
|
+
|
229
|
+
# When set to false, does not sign a user in automatically after their password is
|
230
|
+
# reset. Defaults to true, so a user is signed in automatically after a reset.
|
231
|
+
# config.sign_in_after_reset_password = true
|
232
|
+
|
233
|
+
# ==> Configuration for :encryptable
|
234
|
+
# Allow you to use another hashing or encryption algorithm besides bcrypt (default).
|
235
|
+
# You can use :sha1, :sha512 or algorithms from others authentication tools as
|
236
|
+
# :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
|
237
|
+
# for default behavior) and :restful_authentication_sha1 (then you should set
|
238
|
+
# stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
|
239
|
+
#
|
240
|
+
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
241
|
+
# config.encryptor = :sha512
|
242
|
+
|
243
|
+
# ==> Scopes configuration
|
244
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
245
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
246
|
+
# are using only default views.
|
247
|
+
# config.scoped_views = false
|
248
|
+
|
249
|
+
# Configure the default scope given to Warden. By default it's the first
|
250
|
+
# devise role declared in your routes (usually :user).
|
251
|
+
# config.default_scope = :user
|
252
|
+
|
253
|
+
# Set this configuration to false if you want /users/sign_out to sign out
|
254
|
+
# only the current scope. By default, Devise signs out all scopes.
|
255
|
+
# config.sign_out_all_scopes = true
|
256
|
+
|
257
|
+
# ==> Navigation configuration
|
258
|
+
# Lists the formats that should be treated as navigational. Formats like
|
259
|
+
# :html, should redirect to the sign in page when the user does not have
|
260
|
+
# access, but formats like :xml or :json, should return 401.
|
261
|
+
#
|
262
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
263
|
+
# should add them to the navigational formats lists.
|
264
|
+
#
|
265
|
+
# The "*/*" below is required to match Internet Explorer requests.
|
266
|
+
# config.navigational_formats = ['*/*', :html]
|
267
|
+
|
268
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
269
|
+
config.sign_out_via = :delete
|
270
|
+
|
271
|
+
# ==> OmniAuth
|
272
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
273
|
+
# up on your models and hooks.
|
274
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
275
|
+
|
276
|
+
# ==> Warden configuration
|
277
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
278
|
+
# change the failure app, you can configure them inside the config.warden block.
|
279
|
+
#
|
280
|
+
# config.warden do |manager|
|
281
|
+
# manager.intercept_401 = false
|
282
|
+
# manager.default_strategies(scope: :user).unshift :some_external_strategy
|
283
|
+
# end
|
284
|
+
|
285
|
+
# ==> Mountable engine configurations
|
286
|
+
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
287
|
+
# is mountable, there are some extra configurations to be taken into account.
|
288
|
+
# The following options are available, assuming the engine is mounted as:
|
289
|
+
#
|
290
|
+
# mount MyEngine, at: '/my_engine'
|
291
|
+
#
|
292
|
+
# The router that invoked `devise_for`, in the example above, would be:
|
293
|
+
# config.router_name = :my_engine
|
294
|
+
#
|
295
|
+
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
|
296
|
+
# so you need to do it manually. For the users scope, it would be:
|
297
|
+
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
298
|
+
|
299
|
+
# ==> Turbolinks configuration
|
300
|
+
# If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
|
301
|
+
#
|
302
|
+
# ActiveSupport.on_load(:devise_failure_app) do
|
303
|
+
# include Turbolinks::Controller
|
304
|
+
# end
|
305
|
+
|
306
|
+
# ==> Configuration for :registerable
|
307
|
+
|
308
|
+
# When set to false, does not sign a user in automatically after their password is
|
309
|
+
# changed. Defaults to true, so a user is signed in automatically after changing a password.
|
310
|
+
# config.sign_in_after_change_password = true
|
311
|
+
end
|