rhino_project_core 0.20.0.alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +28 -0
  4. data/Rakefile +35 -0
  5. data/app/assets/stripe_flow.png +0 -0
  6. data/app/controllers/concerns/rhino/authenticated.rb +18 -0
  7. data/app/controllers/concerns/rhino/error_handling.rb +60 -0
  8. data/app/controllers/concerns/rhino/paper_trail_whodunnit.rb +11 -0
  9. data/app/controllers/concerns/rhino/permit.rb +38 -0
  10. data/app/controllers/concerns/rhino/set_current_user.rb +13 -0
  11. data/app/controllers/rhino/account_controller.rb +34 -0
  12. data/app/controllers/rhino/active_model_extension_controller.rb +52 -0
  13. data/app/controllers/rhino/base_controller.rb +23 -0
  14. data/app/controllers/rhino/crud_controller.rb +57 -0
  15. data/app/controllers/rhino/simple_controller.rb +13 -0
  16. data/app/controllers/rhino/simple_stream_controller.rb +12 -0
  17. data/app/helpers/rhino/omniauth_helper.rb +67 -0
  18. data/app/helpers/rhino/policy_helper.rb +42 -0
  19. data/app/helpers/rhino/segment_helper.rb +62 -0
  20. data/app/models/rhino/account.rb +13 -0
  21. data/app/models/rhino/current.rb +7 -0
  22. data/app/models/rhino/user.rb +44 -0
  23. data/app/overrides/active_record/autosave_association_override.rb +18 -0
  24. data/app/overrides/active_record/delegated_type_override.rb +14 -0
  25. data/app/overrides/activestorage/direct_uploads_controller_override.rb +23 -0
  26. data/app/overrides/activestorage/redirect_controller_override.rb +21 -0
  27. data/app/overrides/activestorage/redirect_representation_controller_override.rb +21 -0
  28. data/app/overrides/devise_token_auth/confirmations_controller_override.rb +14 -0
  29. data/app/overrides/devise_token_auth/omniauth_callbacks_controller_override.rb +45 -0
  30. data/app/overrides/devise_token_auth/passwords_controller_override.rb +9 -0
  31. data/app/overrides/devise_token_auth/registrations_controller_override.rb +20 -0
  32. data/app/overrides/devise_token_auth/sessions_controller_override.rb +26 -0
  33. data/app/overrides/devise_token_auth/token_validations_controller_override.rb +18 -0
  34. data/app/policies/rhino/account_policy.rb +27 -0
  35. data/app/policies/rhino/active_storage_attachment_policy.rb +16 -0
  36. data/app/policies/rhino/admin_policy.rb +20 -0
  37. data/app/policies/rhino/base_policy.rb +72 -0
  38. data/app/policies/rhino/crud_policy.rb +109 -0
  39. data/app/policies/rhino/editor_policy.rb +12 -0
  40. data/app/policies/rhino/global_policy.rb +8 -0
  41. data/app/policies/rhino/resource_info_policy.rb +9 -0
  42. data/app/policies/rhino/user_policy.rb +20 -0
  43. data/app/policies/rhino/viewer_policy.rb +19 -0
  44. data/app/resources/rhino/info_graph.rb +41 -0
  45. data/app/resources/rhino/open_api_info.rb +108 -0
  46. data/config/routes.rb +19 -0
  47. data/db/migrate/20180101000000_devise_token_auth_create_users.rb +54 -0
  48. data/db/migrate/20180622142754_add_allow_change_password_to_users.rb +5 -0
  49. data/db/migrate/20191217010224_add_approved_to_users.rb +7 -0
  50. data/db/migrate/20200503182019_change_tokens_to_json_b.rb +9 -0
  51. data/lib/commands/rhino/module/coverage_command.rb +44 -0
  52. data/lib/commands/rhino/module/dummy_command.rb +43 -0
  53. data/lib/commands/rhino/module/new_command.rb +34 -0
  54. data/lib/commands/rhino/module/rails_command.rb +43 -0
  55. data/lib/commands/rhino/module/test_command.rb +43 -0
  56. data/lib/generators/rhino/dev/setup/setup_generator.rb +199 -0
  57. data/lib/generators/rhino/dev/setup/templates/env.client.tt +4 -0
  58. data/lib/generators/rhino/dev/setup/templates/env.root.tt +1 -0
  59. data/lib/generators/rhino/dev/setup/templates/env.server.tt +35 -0
  60. data/lib/generators/rhino/dev/setup/templates/prepare-commit-msg +17 -0
  61. data/lib/generators/rhino/install/install_generator.rb +24 -0
  62. data/lib/generators/rhino/install/templates/account.rb +4 -0
  63. data/lib/generators/rhino/install/templates/rhino.rb +24 -0
  64. data/lib/generators/rhino/install/templates/user.rb +4 -0
  65. data/lib/generators/rhino/model/model_generator.rb +96 -0
  66. data/lib/generators/rhino/module/USAGE +6 -0
  67. data/lib/generators/rhino/module/module_generator.rb +92 -0
  68. data/lib/generators/rhino/module/templates/%name%.gemspec.tt +24 -0
  69. data/lib/generators/rhino/module/templates/lib/%namespaced_name%/engine.rb.tt +18 -0
  70. data/lib/generators/rhino/module/templates/lib/generators/%namespaced_name%/install/install_generator.rb.tt +12 -0
  71. data/lib/generators/rhino/module/templates/lib/tasks/%namespaced_name%_tasks.rake.tt +13 -0
  72. data/lib/generators/rhino/module/templates/test/dummy/app/models/user.rb +4 -0
  73. data/lib/generators/rhino/module/templates/test/dummy/config/database.yml +25 -0
  74. data/lib/generators/rhino/module/templates/test/dummy/config/initializers/devise.rb +311 -0
  75. data/lib/generators/rhino/module/templates/test/dummy/config/initializers/devise_token_auth.rb +71 -0
  76. data/lib/generators/rhino/module/templates/test/test_helper.rb +54 -0
  77. data/lib/generators/rhino/policy/policy_generator.rb +33 -0
  78. data/lib/generators/rhino/policy/templates/policy.rb.tt +46 -0
  79. data/lib/generators/test_unit/rhino_policy_generator.rb +13 -0
  80. data/lib/generators/test_unit/templates/policy_test.rb.tt +57 -0
  81. data/lib/rhino/engine.rb +166 -0
  82. data/lib/rhino/omniauth/strategies/azure_o_auth2.rb +16 -0
  83. data/lib/rhino/resource/active_model_extension/backing_store/google_sheet.rb +89 -0
  84. data/lib/rhino/resource/active_model_extension/backing_store.rb +33 -0
  85. data/lib/rhino/resource/active_model_extension/describe.rb +38 -0
  86. data/lib/rhino/resource/active_model_extension/params.rb +70 -0
  87. data/lib/rhino/resource/active_model_extension/properties.rb +231 -0
  88. data/lib/rhino/resource/active_model_extension/reference.rb +50 -0
  89. data/lib/rhino/resource/active_model_extension/routing.rb +15 -0
  90. data/lib/rhino/resource/active_model_extension/serialization.rb +16 -0
  91. data/lib/rhino/resource/active_model_extension.rb +38 -0
  92. data/lib/rhino/resource/active_record_extension/describe.rb +44 -0
  93. data/lib/rhino/resource/active_record_extension/params.rb +213 -0
  94. data/lib/rhino/resource/active_record_extension/properties.rb +85 -0
  95. data/lib/rhino/resource/active_record_extension/properties_describe.rb +228 -0
  96. data/lib/rhino/resource/active_record_extension/reference.rb +50 -0
  97. data/lib/rhino/resource/active_record_extension/routing.rb +21 -0
  98. data/lib/rhino/resource/active_record_extension/search.rb +23 -0
  99. data/lib/rhino/resource/active_record_extension/serialization.rb +16 -0
  100. data/lib/rhino/resource/active_record_extension/super_admin.rb +25 -0
  101. data/lib/rhino/resource/active_record_extension.rb +32 -0
  102. data/lib/rhino/resource/active_record_tree.rb +50 -0
  103. data/lib/rhino/resource/active_storage_extension.rb +41 -0
  104. data/lib/rhino/resource/describe.rb +19 -0
  105. data/lib/rhino/resource/owner.rb +172 -0
  106. data/lib/rhino/resource/params.rb +31 -0
  107. data/lib/rhino/resource/properties.rb +192 -0
  108. data/lib/rhino/resource/reference.rb +29 -0
  109. data/lib/rhino/resource/routing.rb +107 -0
  110. data/lib/rhino/resource/serialization.rb +13 -0
  111. data/lib/rhino/resource/sieves.rb +36 -0
  112. data/lib/rhino/resource.rb +55 -0
  113. data/lib/rhino/sieve/filter.rb +149 -0
  114. data/lib/rhino/sieve/geospatial.rb +45 -0
  115. data/lib/rhino/sieve/helpers.rb +11 -0
  116. data/lib/rhino/sieve/limit.rb +20 -0
  117. data/lib/rhino/sieve/offset.rb +16 -0
  118. data/lib/rhino/sieve/order.rb +143 -0
  119. data/lib/rhino/sieve/search.rb +20 -0
  120. data/lib/rhino/sieve.rb +159 -0
  121. data/lib/rhino/test_case/controller.rb +145 -0
  122. data/lib/rhino/test_case/model.rb +86 -0
  123. data/lib/rhino/test_case/override.rb +19 -0
  124. data/lib/rhino/test_case/policy.rb +76 -0
  125. data/lib/rhino/test_case.rb +11 -0
  126. data/lib/rhino/version.rb +17 -0
  127. data/lib/rhino_project_core.rb +131 -0
  128. data/lib/tasks/rhino.rake +24 -0
  129. data/lib/tasks/rhino_dev.rake +17 -0
  130. data/lib/validators/country_validator.rb +11 -0
  131. data/lib/validators/email_validator.rb +8 -0
  132. data/lib/validators/ipv4_validator.rb +10 -0
  133. data/lib/validators/mac_address_validator.rb +9 -0
  134. metadata +531 -0
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rhino
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+ source_root File.expand_path('templates', __dir__)
7
+
8
+ def install_user
9
+ say 'Installing user to app/models'
10
+ template 'user.rb', 'app/models/user.rb'
11
+ end
12
+
13
+ def install_account
14
+ say 'Installing account to app/models'
15
+ template 'account.rb', 'app/models/account.rb'
16
+ end
17
+
18
+ def install_initializer
19
+ say 'Installing initializer'
20
+ template 'rhino.rb', 'config/initializers/rhino.rb'
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Account < Rhino::Account
4
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rhino.setup do |config|
4
+ # ==> Owner configuration
5
+ # The auth owner class
6
+ # config.auth_owner = 'User'
7
+
8
+ # The base owner class
9
+ # config.base_owner = 'Organization'
10
+
11
+ # ==> Resource Configuration
12
+
13
+ # Include Rhino::Resource::ActiveRecordExtension by default
14
+ # config.auto_include_active_record = true
15
+
16
+ # The root path for the api ie '/api'
17
+ # config.namespace = :api
18
+
19
+ # Authentication
20
+ # config.allow_signup = true
21
+
22
+ # The list of resources exposed in the API
23
+ config.resources += ['User', 'Account']
24
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class User < Rhino::User
4
+ end
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+ require "rails/generators/active_record/model/model_generator"
5
+
6
+ module Rhino
7
+ class ModelGenerator < ::ActiveRecord::Generators::ModelGenerator
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ class_option :owner, type: :string, desc: "The model is owned by the reference attribute", group: :owner
11
+ class_option :base_owner, type: :boolean, default: false, desc: "The model is owned by the base owner", group: :owner
12
+ class_option :global_owner, type: :boolean, default: false, desc: "The model is globally owned", group: :owner
13
+
14
+ # Parent source paths
15
+ def source_paths
16
+ [
17
+ File.expand_path("templates", __dir__),
18
+ ::ActiveRecord::Generators::ModelGenerator.source_root
19
+ ]
20
+ end
21
+
22
+ def create_migration_file
23
+ # We check the ownership of the reference attributes before creating the migration
24
+ check_ownership
25
+
26
+ super
27
+ end
28
+
29
+ def inject_into_rhino_initializer
30
+ # FIXME: Can we do better on indentation?
31
+ inject_into_file "config/initializers/rhino.rb", before: /^end\s*$/ do
32
+ " config.resources += ['#{class_name}']\n"
33
+ end
34
+ end
35
+
36
+ def inject_rhino_owner_into_model
37
+ # Write 'rhino_owner :<attribute name>' to the model file
38
+ model_file = File.join("app/models", "#{file_path}.rb")
39
+
40
+ # FIXME: Can we do better on indentation?
41
+ inject_into_file model_file, before: /^end\s*$/ do
42
+ "\n #{owner_call}\n"
43
+ end
44
+
45
+ # Global owned don't need a reference
46
+ return if global_owner?
47
+
48
+ inject_into_file model_file, after: /#{owner_call}/ do
49
+ "\n rhino_references %i[#{owner_name}]"
50
+ end
51
+ end
52
+
53
+ protected
54
+ def check_ownership
55
+ raise Thor::Error, "Exactly one owner must be defined on a reference or globally" unless base_owner? ^ global_owner? ^ reference_owner?
56
+
57
+ return if global_owner? || reference_attributes.find { |attr| attr.name == owner_name }
58
+
59
+ raise Thor::Error, "The owner attribute must be a reference attribute"
60
+ end
61
+
62
+ private
63
+ def global_owner?
64
+ @global_owner = options[:global_owner]
65
+ end
66
+
67
+ def base_owner?
68
+ @global_owner = options[:base_owner] || Rhino.base_owner.model_name.singular == options[:owner]
69
+ end
70
+
71
+ def reference_owner?
72
+ @reference_owner = options[:owner].present? && !base_owner?
73
+ end
74
+
75
+ def owner_name
76
+ @owner_name ||= if global_owner?
77
+ "global"
78
+ elsif base_owner?
79
+ Rhino.base_owner.model_name.singular
80
+ else
81
+ options[:owner]
82
+ end
83
+ end
84
+
85
+ def owner_call
86
+ return "rhino_owner_global" if global_owner?
87
+ return "rhino_owner_base" if base_owner?
88
+
89
+ "rhino_owner :#{owner_name}"
90
+ end
91
+
92
+ def reference_attributes
93
+ @reference_attributes ||= attributes.filter(&:reference?)
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,6 @@
1
+ Description:
2
+ The 'rails rhino:module' command creates a skeleton for developing Rhino modules.
3
+
4
+ Example:
5
+ rails rhino:module:new rhino_my_module
6
+
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+ require "rails/generators/rails/plugin/plugin_generator"
5
+ require "rhino/version"
6
+
7
+ module Rhino
8
+ module Generators
9
+ class ModuleBuilder < ::Rails::PluginBuilder
10
+ def lib
11
+ template "lib/%namespaced_name%.rb"
12
+ template "lib/%namespaced_name%/version.rb"
13
+
14
+ template "lib/%namespaced_name%/engine.rb"
15
+
16
+ # The install generator
17
+ empty_directory_with_keep_file "lib/generators/#{namespaced_name}/install/templates"
18
+ template "lib/generators/%namespaced_name%/install/install_generator.rb"
19
+ template "lib/tasks/%namespaced_name%_tasks.rake"
20
+ end
21
+
22
+ # FIXME: Hack because the engine.rb file is over aggressive in its checks
23
+ def rhino_hack
24
+ template "test/dummy/config/initializers/devise.rb"
25
+ template "test/dummy/config/initializers/devise_token_auth.rb"
26
+ template "test/dummy/app/models/user.rb"
27
+ remove_file "test/dummy/config/database.yml"
28
+ template "test/dummy/config/database.yml"
29
+ end
30
+ end
31
+
32
+ class ModuleGenerator < ::Rails::Generators::PluginGenerator
33
+ source_root File.expand_path("templates", __dir__)
34
+
35
+ class_option :database, type: :string, aliases: "-d", default: "postgresql", hide: true
36
+ class_option :full, type: :boolean, default: true, hide: true
37
+ remove_class_option :template
38
+
39
+ def self.banner
40
+ "rails rhino:module #{arguments.map(&:usage).join(' ')} [options]"
41
+ end
42
+
43
+ # Parent source paths
44
+ def source_paths
45
+ [
46
+ File.expand_path("templates", __dir__),
47
+ Rails::Generators::PluginGenerator.source_root
48
+ ]
49
+ end
50
+
51
+ # Has to be named this way as it overrides the default
52
+ def get_builder_class # rubocop:disable Naming/AccessorMethodName
53
+ ModuleBuilder
54
+ end
55
+
56
+ def engine_config
57
+ content = []
58
+
59
+ content << "isolate_namespace #{camelized_modules}\n" if mountable?
60
+ content << "config.generators.api_only = true" if api?
61
+
62
+ return optimize_indentation(content.join("\n"), 4) if content.any?
63
+
64
+ nil
65
+ end
66
+
67
+ def rhino_version
68
+ ::Rhino::VERSION::STRING
69
+ end
70
+
71
+ def rhino_setup
72
+ return unless with_dummy_app?
73
+
74
+ build(:rhino_hack)
75
+
76
+ inside(rails_app_path) do
77
+ run "rails rhino:module:dummy #{namespaced_name} rhino:install"
78
+ run "rails rhino:module:dummy #{namespaced_name} db:create"
79
+ run "rails rhino:module:dummy #{namespaced_name} db:migrate"
80
+ end
81
+ end
82
+
83
+ def rubocop
84
+ template ".rubocop.yml"
85
+
86
+ inside(File.join(rails_app_path, namespaced_name)) do
87
+ run "bundle exec rubocop -A ", capture: true
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,24 @@
1
+ require_relative "lib/<%= namespaced_name %>/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = <%= name.inspect %>
5
+ spec.version = <%= camelized_modules %>::VERSION
6
+ spec.authors = [ <%= author.inspect %> ]
7
+ spec.email = [ <%= email.inspect %> ]
8
+ spec.summary = "Summary of <%= camelized_modules %>."
9
+ spec.description = "Description of <%= camelized_modules %>."
10
+ <%- unless inside_application? -%>
11
+ spec.license = "MIT"
12
+ <%- end -%>
13
+
14
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the "allowed_push_host"
15
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
16
+ spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
17
+
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ Dir["{app,config,db,lib}/**/*", <%- unless inside_application? -%> "MIT-LICENSE", <%- end -%>"Rakefile", "README.md"]
20
+ end
21
+
22
+ <%= "# " if rails_prerelease? -%>spec.add_dependency "rails", "<%= Array(rails_version_specifier).join('", "') %>"
23
+ spec.add_dependency "rhino_project_core", ">= <%= rhino_version %>"
24
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rhino/engine"
4
+
5
+ module <%= camelized_modules %>
6
+ class Engine < ::Rails::Engine
7
+ <%= engine_config -%>
8
+ config.autoload_paths << File.expand_path("../../lib", __dir__)
9
+
10
+ initializer "<%= namespaced_name %>.register_module" do
11
+ config.after_initialize do
12
+ Rhino.registered_modules[:<%= namespaced_name %>] = {
13
+ version: <%= camelized_modules %>::VERSION
14
+ }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= camelized_modules %>
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ def install
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :<%= namespaced_name %> do
4
+ # Prevent migration installation task from showing up twice.
5
+ Rake::Task["<%= namespaced_name %>_engine:install:migrations"].clear_comments if Rake::Task.task_defined?("<%= namespaced_name %>_engine:install:migrations")
6
+
7
+ desc "Install <%= namespaced_name %>"
8
+ task install: :environment do
9
+ Rake::Task["<%= namespaced_name %>_engine:install:migrations"].invoke if Rake::Task.task_defined?("<%= namespaced_name %>_engine:install:migrations")
10
+
11
+ Rails::Command.invoke :generate, ["<%= namespaced_name %>:install"]
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class User < Rhino::User
4
+ end
@@ -0,0 +1,25 @@
1
+ default: &default
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ pool: 5
5
+ username: <%%= ENV["DB_USERNAME"] %>
6
+ password: <%%= ENV["DB_PASSWORD"] %>
7
+ database: <%%= ENV["DB_NAME"] %>
8
+ port: <%%= ENV["DB_PORT"] || 5432 %>
9
+ host: <%%= ENV["DB_HOST"] || "localhost" %>
10
+
11
+ development:
12
+ <<: *default
13
+ database: <%%= ENV["DB_NAME"] %>_development
14
+
15
+ # Warning: The database defined as "test" will be erased and
16
+ # re-generated from your development database when you run "rake".
17
+ # Do not set this db to the same as development or production.
18
+ test:
19
+ <<: *default
20
+ # https://github.com/ged/ruby-pg/issues/311#issuecomment-1615084569
21
+ gssencmode: disable
22
+ database: <%%= ENV["DB_NAME"] %>_test
23
+
24
+ production:
25
+ <<: *default
@@ -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 = '1b7b3cb6c9406b83c9dee1e2408d312241fcf7228320bd533d8f619531abdc5203f74296f2fc560753c2117f37f8533d841ced6be9ed6c9fe2f913d576db6dd2'
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 = ENV.fetch("DEFAULT_EMAIL_SENDER", "from@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 = '82ac2dcad675b91cf651a60b4bbc6c44403cd3ef47af621fca84f8e91d7bf0d45a058e6444eb4dbf787c3d9f7b9ed42a86a469d20dc67046816815c6f40cbb6d'
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