devise_token_auth_skycocker_fork 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +13 -0
- data/README.md +97 -0
- data/Rakefile +42 -0
- data/app/controllers/devise_token_auth/application_controller.rb +79 -0
- data/app/controllers/devise_token_auth/concerns/resource_finder.rb +44 -0
- data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +178 -0
- data/app/controllers/devise_token_auth/confirmations_controller.rb +39 -0
- data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +239 -0
- data/app/controllers/devise_token_auth/passwords_controller.rb +185 -0
- data/app/controllers/devise_token_auth/registrations_controller.rb +198 -0
- data/app/controllers/devise_token_auth/sessions_controller.rb +131 -0
- data/app/controllers/devise_token_auth/token_validations_controller.rb +31 -0
- data/app/controllers/devise_token_auth/unlocks_controller.rb +89 -0
- data/app/models/devise_token_auth/concerns/active_record_support.rb +34 -0
- data/app/models/devise_token_auth/concerns/mongoid_support.rb +19 -0
- data/app/models/devise_token_auth/concerns/user.rb +262 -0
- data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +28 -0
- data/app/validators/devise_token_auth/email_validator.rb +23 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise_token_auth/omniauth_external_window.html.erb +38 -0
- data/config/locales/da-DK.yml +50 -0
- data/config/locales/de.yml +49 -0
- data/config/locales/en.yml +50 -0
- data/config/locales/es.yml +49 -0
- data/config/locales/fr.yml +49 -0
- data/config/locales/it.yml +46 -0
- data/config/locales/ja.yml +46 -0
- data/config/locales/nl.yml +30 -0
- data/config/locales/pl.yml +48 -0
- data/config/locales/pt-BR.yml +46 -0
- data/config/locales/pt.yml +48 -0
- data/config/locales/ro.yml +46 -0
- data/config/locales/ru.yml +50 -0
- data/config/locales/sq.yml +46 -0
- data/config/locales/sv.yml +50 -0
- data/config/locales/uk.yml +59 -0
- data/config/locales/vi.yml +50 -0
- data/config/locales/zh-CN.yml +46 -0
- data/config/locales/zh-HK.yml +48 -0
- data/config/locales/zh-TW.yml +48 -0
- data/lib/devise_token_auth.rb +13 -0
- data/lib/devise_token_auth/blacklist.rb +2 -0
- data/lib/devise_token_auth/controllers/helpers.rb +161 -0
- data/lib/devise_token_auth/controllers/url_helpers.rb +10 -0
- data/lib/devise_token_auth/engine.rb +90 -0
- data/lib/devise_token_auth/errors.rb +8 -0
- data/lib/devise_token_auth/rails/routes.rb +116 -0
- data/lib/devise_token_auth/url.rb +41 -0
- data/lib/devise_token_auth/version.rb +5 -0
- data/lib/generators/devise_token_auth/USAGE +31 -0
- data/lib/generators/devise_token_auth/install_generator.rb +91 -0
- data/lib/generators/devise_token_auth/install_generator_helpers.rb +98 -0
- data/lib/generators/devise_token_auth/install_mongoid_generator.rb +46 -0
- data/lib/generators/devise_token_auth/install_views_generator.rb +18 -0
- data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +50 -0
- data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +56 -0
- data/lib/generators/devise_token_auth/templates/user.rb.erb +9 -0
- data/lib/generators/devise_token_auth/templates/user_mongoid.rb.erb +63 -0
- data/lib/tasks/devise_token_auth_tasks.rake +6 -0
- data/test/controllers/custom/custom_confirmations_controller_test.rb +25 -0
- data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +33 -0
- data/test/controllers/custom/custom_passwords_controller_test.rb +79 -0
- data/test/controllers/custom/custom_registrations_controller_test.rb +63 -0
- data/test/controllers/custom/custom_sessions_controller_test.rb +39 -0
- data/test/controllers/custom/custom_token_validations_controller_test.rb +42 -0
- data/test/controllers/demo_group_controller_test.rb +151 -0
- data/test/controllers/demo_mang_controller_test.rb +284 -0
- data/test/controllers/demo_user_controller_test.rb +629 -0
- data/test/controllers/devise_token_auth/confirmations_controller_test.rb +127 -0
- data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +376 -0
- data/test/controllers/devise_token_auth/passwords_controller_test.rb +639 -0
- data/test/controllers/devise_token_auth/registrations_controller_test.rb +880 -0
- data/test/controllers/devise_token_auth/sessions_controller_test.rb +541 -0
- data/test/controllers/devise_token_auth/token_validations_controller_test.rb +102 -0
- data/test/controllers/devise_token_auth/unlocks_controller_test.rb +196 -0
- data/test/controllers/overrides/confirmations_controller_test.rb +47 -0
- data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +53 -0
- data/test/controllers/overrides/passwords_controller_test.rb +64 -0
- data/test/controllers/overrides/registrations_controller_test.rb +46 -0
- data/test/controllers/overrides/sessions_controller_test.rb +35 -0
- data/test/controllers/overrides/token_validations_controller_test.rb +43 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/app/active_record/lockable_user.rb +7 -0
- data/test/dummy/app/active_record/mang.rb +5 -0
- data/test/dummy/app/active_record/only_email_user.rb +7 -0
- data/test/dummy/app/active_record/scoped_user.rb +9 -0
- data/test/dummy/app/active_record/unconfirmable_user.rb +9 -0
- data/test/dummy/app/active_record/unregisterable_user.rb +9 -0
- data/test/dummy/app/active_record/user.rb +6 -0
- data/test/dummy/app/controllers/application_controller.rb +18 -0
- data/test/dummy/app/controllers/auth_origin_controller.rb +7 -0
- data/test/dummy/app/controllers/custom/confirmations_controller.rb +13 -0
- data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +13 -0
- data/test/dummy/app/controllers/custom/passwords_controller.rb +39 -0
- data/test/dummy/app/controllers/custom/registrations_controller.rb +39 -0
- data/test/dummy/app/controllers/custom/sessions_controller.rb +29 -0
- data/test/dummy/app/controllers/custom/token_validations_controller.rb +19 -0
- data/test/dummy/app/controllers/demo_group_controller.rb +15 -0
- data/test/dummy/app/controllers/demo_mang_controller.rb +14 -0
- data/test/dummy/app/controllers/demo_user_controller.rb +27 -0
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +28 -0
- data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +16 -0
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +35 -0
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +29 -0
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +36 -0
- data/test/dummy/app/controllers/overrides/token_validations_controller.rb +23 -0
- data/test/dummy/app/helpers/application_helper.rb +1058 -0
- data/test/dummy/app/models/concerns/favorite_color.rb +19 -0
- data/test/dummy/app/mongoid/lockable_user.rb +38 -0
- data/test/dummy/app/mongoid/mang.rb +53 -0
- data/test/dummy/app/mongoid/only_email_user.rb +33 -0
- data/test/dummy/app/mongoid/scoped_user.rb +57 -0
- data/test/dummy/app/mongoid/unconfirmable_user.rb +51 -0
- data/test/dummy/app/mongoid/unregisterable_user.rb +54 -0
- data/test/dummy/app/mongoid/user.rb +56 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +18 -0
- data/test/dummy/config/application.rb +48 -0
- data/test/dummy/config/application.yml.bk +0 -0
- data/test/dummy/config/boot.rb +11 -0
- data/test/dummy/config/environment.rb +7 -0
- data/test/dummy/config/environments/development.rb +46 -0
- data/test/dummy/config/environments/production.rb +84 -0
- data/test/dummy/config/environments/test.rb +50 -0
- data/test/dummy/config/initializers/assets.rb +10 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +9 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/devise.rb +17 -0
- data/test/dummy/config/initializers/devise_token_auth.rb +24 -0
- data/test/dummy/config/initializers/figaro.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/test/dummy/config/initializers/inflections.rb +18 -0
- data/test/dummy/config/initializers/mime_types.rb +6 -0
- data/test/dummy/config/initializers/omniauth.rb +10 -0
- data/test/dummy/config/initializers/session_store.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/test/dummy/config/routes.rb +55 -0
- data/test/dummy/config/spring.rb +3 -0
- data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +65 -0
- data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +64 -0
- data/test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb +8 -0
- data/test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb +7 -0
- data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +62 -0
- data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +63 -0
- data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +63 -0
- data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +63 -0
- data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +63 -0
- data/test/dummy/db/schema.rb +200 -0
- data/test/dummy/lib/migration_database_helper.rb +43 -0
- data/test/dummy/tmp/generators/app/models/user.rb +9 -0
- data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +50 -0
- data/test/dummy/tmp/generators/db/migrate/20181030122248_devise_token_auth_create_users.rb +56 -0
- data/test/factories/users.rb +40 -0
- data/test/lib/devise_token_auth/blacklist_test.rb +11 -0
- data/test/lib/devise_token_auth/url_test.rb +26 -0
- data/test/lib/generators/devise_token_auth/install_generator_test.rb +217 -0
- data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +222 -0
- data/test/lib/generators/devise_token_auth/install_views_generator_test.rb +25 -0
- data/test/models/concerns/mongoid_support_test.rb +31 -0
- data/test/models/only_email_user_test.rb +37 -0
- data/test/models/user_test.rb +140 -0
- data/test/support/controllers/routes.rb +43 -0
- data/test/test_helper.rb +103 -0
- metadata +443 -0
Binary file
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
unless defined?(DEVISE_TOKEN_AUTH_ORM)
|
4
|
+
DEVISE_TOKEN_AUTH_ORM = (ENV["DEVISE_TOKEN_AUTH_ORM"] || :active_record).to_sym
|
5
|
+
end
|
6
|
+
|
7
|
+
# Set up gems listed in the Gemfile.
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
|
9
|
+
|
10
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
11
|
+
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
|
@@ -0,0 +1,46 @@
|
|
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 and disable caching.
|
15
|
+
config.consider_all_requests_local = true
|
16
|
+
config.action_controller.perform_caching = false
|
17
|
+
|
18
|
+
# Don't care if the mailer can't send.
|
19
|
+
config.action_mailer.raise_delivery_errors = true
|
20
|
+
|
21
|
+
# use mailcatcher for development
|
22
|
+
config.action_mailer.default_url_options = { host: 'devise-token-auth.dev' }
|
23
|
+
config.action_mailer.delivery_method = :smtp
|
24
|
+
config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 }
|
25
|
+
|
26
|
+
# Print deprecation notices to the Rails logger.
|
27
|
+
config.active_support.deprecation = :log
|
28
|
+
|
29
|
+
# Raise an error on page load if there are pending migrations.
|
30
|
+
config.active_record.migration_error = :page_load
|
31
|
+
|
32
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
33
|
+
# This option may cause significant delays in view rendering with a large
|
34
|
+
# number of complex assets.
|
35
|
+
config.assets.debug = true
|
36
|
+
|
37
|
+
# Adds additional error checking when serving assets at runtime.
|
38
|
+
# Checks for improperly declared sprockets dependencies.
|
39
|
+
# Raises helpful error messages.
|
40
|
+
config.assets.raise_runtime_errors = true
|
41
|
+
|
42
|
+
# Raises error for missing translations
|
43
|
+
# config.action_view.raise_on_missing_translations = true
|
44
|
+
|
45
|
+
OmniAuth.config.full_host = 'http://devise-token-auth.dev'
|
46
|
+
end
|
@@ -0,0 +1,84 @@
|
|
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
|
+
# Code is not reloaded between requests.
|
7
|
+
config.cache_classes = true
|
8
|
+
|
9
|
+
# Eager load code on boot. This eager loads most of Rails and
|
10
|
+
# your application in memory, allowing both threaded web servers
|
11
|
+
# and those relying on copy on write to perform better.
|
12
|
+
# Rake tasks automatically ignore this option for performance.
|
13
|
+
config.eager_load = true
|
14
|
+
|
15
|
+
# Full error reports are disabled and caching is turned on.
|
16
|
+
config.consider_all_requests_local = false
|
17
|
+
config.action_controller.perform_caching = true
|
18
|
+
|
19
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
20
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
21
|
+
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
22
|
+
# config.action_dispatch.rack_cache = true
|
23
|
+
|
24
|
+
# Disable Rails's static asset server (Apache or nginx will already do this).
|
25
|
+
config.serve_static_files = false
|
26
|
+
|
27
|
+
# Compress JavaScripts and CSS.
|
28
|
+
config.assets.js_compressor = :uglifier
|
29
|
+
# config.assets.css_compressor = :sass
|
30
|
+
|
31
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
32
|
+
config.assets.compile = false
|
33
|
+
|
34
|
+
# Generate digests for assets URLs.
|
35
|
+
config.assets.digest = true
|
36
|
+
|
37
|
+
# `config.assets.precompile` has moved to config/initializers/assets.rb
|
38
|
+
|
39
|
+
# Specifies the header that your server uses for sending files.
|
40
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
41
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
42
|
+
|
43
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
44
|
+
# config.force_ssl = true
|
45
|
+
|
46
|
+
# Set to :debug to see everything in the log.
|
47
|
+
config.log_level = :info
|
48
|
+
|
49
|
+
# Prepend all log lines with the following tags.
|
50
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
51
|
+
|
52
|
+
# Use a different logger for distributed setups.
|
53
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
54
|
+
|
55
|
+
# Use a different cache store in production.
|
56
|
+
# config.cache_store = :mem_cache_store
|
57
|
+
|
58
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
59
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
60
|
+
|
61
|
+
# Precompile additional assets.
|
62
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
63
|
+
# config.assets.precompile += %w( search.js )
|
64
|
+
|
65
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
66
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
67
|
+
# config.action_mailer.raise_delivery_errors = false
|
68
|
+
|
69
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
70
|
+
# the I18n.default_locale when a translation cannot be found).
|
71
|
+
config.i18n.fallbacks = true
|
72
|
+
|
73
|
+
# Send deprecation notices to registered listeners.
|
74
|
+
config.active_support.deprecation = :notify
|
75
|
+
|
76
|
+
# Disable automatic flushing of the log to improve performance.
|
77
|
+
# config.autoflush_log = false
|
78
|
+
|
79
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
80
|
+
config.log_formatter = ::Logger::Formatter.new
|
81
|
+
|
82
|
+
# Do not dump schema after migrations.
|
83
|
+
config.active_record.dump_schema_after_migration = false
|
84
|
+
end
|
@@ -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
|
+
# The test environment is used exclusively to run your application's
|
7
|
+
# test suite. You never need to work with it otherwise. Remember that
|
8
|
+
# your test database is "scratch space" for the test suite and is wiped
|
9
|
+
# and recreated between test runs. Don't rely on the data there!
|
10
|
+
config.cache_classes = true
|
11
|
+
|
12
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
13
|
+
# just for the purpose of running a single test. If you are using a tool that
|
14
|
+
# preloads Rails for running tests, you may have to set it to true.
|
15
|
+
config.eager_load = false
|
16
|
+
|
17
|
+
# Configure static asset server for tests with Cache-Control for performance.
|
18
|
+
Rails::VERSION::MAJOR == 5 ?
|
19
|
+
(config.public_file_server.enabled = true) :
|
20
|
+
(config.serve_static_files = true)
|
21
|
+
|
22
|
+
Rails::VERSION::MAJOR == 5 ?
|
23
|
+
(config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }) :
|
24
|
+
(config.static_cache_control = 'public, max-age=3600')
|
25
|
+
|
26
|
+
# Show full error reports and disable caching.
|
27
|
+
config.consider_all_requests_local = true
|
28
|
+
config.action_controller.perform_caching = false
|
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
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
37
|
+
# The :test delivery method accumulates sent emails in the
|
38
|
+
# ActionMailer::Base.deliveries array.
|
39
|
+
config.action_mailer.delivery_method = :test
|
40
|
+
config.action_mailer.default_url_options = { host: 'localhost' }
|
41
|
+
|
42
|
+
# Print deprecation notices to the stderr.
|
43
|
+
config.active_support.deprecation = :stderr
|
44
|
+
|
45
|
+
# Raises error for missing translations
|
46
|
+
# config.action_view.raise_on_missing_translations = true
|
47
|
+
|
48
|
+
# randomize test order
|
49
|
+
config.active_support.test_order = :random
|
50
|
+
end
|
@@ -0,0 +1,10 @@
|
|
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
|
+
# Precompile additional assets.
|
9
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
10
|
+
# Rails.application.config.assets.precompile += %w( search.js )
|
@@ -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,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Devise.setup do |config|
|
4
|
+
config.authentication_keys = [:email, :nickname]
|
5
|
+
|
6
|
+
# ==> Mailer Configuration
|
7
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
8
|
+
# note that it will be overwritten if you use your own mailer class
|
9
|
+
# with default "from" parameter.
|
10
|
+
config.mailer_sender = 'no-reply@example.com'
|
11
|
+
|
12
|
+
# ==> ORM configuration
|
13
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
14
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
15
|
+
# available as additional gems.
|
16
|
+
require "devise/orm/#{DEVISE_TOKEN_AUTH_ORM}"
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
DeviseTokenAuth.setup do |config|
|
4
|
+
# By default the authorization headers will change after each request. The
|
5
|
+
# client is responsible for keeping track of the changing tokens. Change
|
6
|
+
# this to false to prevent the Authorization header from changing after
|
7
|
+
# each request.
|
8
|
+
#config.change_headers_on_each_request = true
|
9
|
+
|
10
|
+
# By default, users will need to re-authenticate after 2 weeks. This setting
|
11
|
+
# determines how long tokens will remain valid after they are issued.
|
12
|
+
#config.token_lifespan = 2.weeks
|
13
|
+
|
14
|
+
# Sometimes it's necessary to make several requests to the API at the same
|
15
|
+
# time. In this case, each request in the batch will need to share the same
|
16
|
+
# auth token. This setting determines how far apart the requests can be while
|
17
|
+
# still using the same auth token.
|
18
|
+
#config.batch_request_buffer_throttle = 5.seconds
|
19
|
+
|
20
|
+
# This route will be the prefix for all oauth2 redirect callbacks. For
|
21
|
+
# example, using the default '/omniauth', the github oauth2 provider will
|
22
|
+
# redirect successful authentications to '/omniauth/github/callback'
|
23
|
+
#config.omniauth_prefix = "/omniauth"
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Be sure to restart your server when you modify this file.
|
4
|
+
|
5
|
+
# Add new inflection rules using the following format. Inflections
|
6
|
+
# are locale specific, and you may define rules for as many different
|
7
|
+
# locales as you wish. All of these examples are active by default:
|
8
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
9
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
10
|
+
# inflect.singular /^(ox)en/i, '\1'
|
11
|
+
# inflect.irregular 'person', 'people'
|
12
|
+
# inflect.uncountable %w( fish sheep )
|
13
|
+
# end
|
14
|
+
|
15
|
+
# These inflection rules are supported but not enabled by default:
|
16
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
17
|
+
# inflect.acronym 'RESTful'
|
18
|
+
# end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Rails.application.config.middleware.use OmniAuth::Builder do |b|
|
4
|
+
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: 'email,profile'
|
5
|
+
provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET']
|
6
|
+
provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET']
|
7
|
+
provider :developer,
|
8
|
+
fields: [:first_name, :last_name],
|
9
|
+
uid_field: :last_name
|
10
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Be sure to restart your server when you modify this file.
|
4
|
+
|
5
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
6
|
+
# is enabled by default.
|
7
|
+
|
8
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
9
|
+
ActiveSupport.on_load(:action_controller) do
|
10
|
+
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
11
|
+
end
|
12
|
+
|
13
|
+
# To enable root element in JSON for ActiveRecord objects.
|
14
|
+
# ActiveSupport.on_load(:active_record) do
|
15
|
+
# self.include_root_in_json = true
|
16
|
+
# end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Rails.application.routes.draw do
|
4
|
+
# when using multiple models, controllers will default to the first available
|
5
|
+
# devise mapping. routes for subsequent devise mappings will need to defined
|
6
|
+
# within a `devise_scope` block
|
7
|
+
|
8
|
+
# define :users as the first devise mapping:
|
9
|
+
mount_devise_token_auth_for 'User', at: 'auth'
|
10
|
+
|
11
|
+
# define :mangs as the second devise mapping. routes using this class will
|
12
|
+
# need to be defined within a devise_scope as shown below
|
13
|
+
mount_devise_token_auth_for 'Mang', at: 'mangs'
|
14
|
+
|
15
|
+
mount_devise_token_auth_for 'OnlyEmailUser', at: 'only_email_auth', skip: [:omniauth_callbacks]
|
16
|
+
|
17
|
+
mount_devise_token_auth_for 'UnregisterableUser', at: 'unregisterable_user_auth', skip: [:registrations]
|
18
|
+
|
19
|
+
mount_devise_token_auth_for 'UnconfirmableUser', at: 'unconfirmable_user_auth'
|
20
|
+
|
21
|
+
mount_devise_token_auth_for 'LockableUser', at: 'lockable_user_auth'
|
22
|
+
|
23
|
+
# test namespacing
|
24
|
+
namespace :api do
|
25
|
+
scope :v1 do
|
26
|
+
mount_devise_token_auth_for 'User', at: 'auth'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# test namespacing with not created devise mapping
|
31
|
+
namespace :api_v2, defaults: { format: :json } do
|
32
|
+
mount_devise_token_auth_for 'ScopedUser',
|
33
|
+
at: 'auth',
|
34
|
+
controllers: {
|
35
|
+
omniauth_callbacks: 'api_v2/omniauth_callbacks',
|
36
|
+
sessions: 'api_v2/sessions',
|
37
|
+
registrations: 'api_v2/registrations',
|
38
|
+
confirmations: 'api_v2/confirmations',
|
39
|
+
passwords: 'api_v2/passwords'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# this route will authorize visitors using the User class
|
44
|
+
get 'demo/members_only', to: 'demo_user#members_only'
|
45
|
+
get 'demo/members_only_remove_token', to: 'demo_user#members_only_remove_token'
|
46
|
+
|
47
|
+
# routes within this block will authorize visitors using the Mang class
|
48
|
+
get 'demo/members_only_mang', to: 'demo_mang#members_only'
|
49
|
+
|
50
|
+
# routes within this block will authorize visitors using the Mang or User class
|
51
|
+
get 'demo/members_only_group', to: 'demo_group#members_only'
|
52
|
+
|
53
|
+
# we need a route for omniauth_callback_controller to redirect to in sameWindow case
|
54
|
+
get 'auth_origin', to: 'auth_origin#redirected'
|
55
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
include MigrationDatabaseHelper
|
4
|
+
|
5
|
+
class DeviseTokenAuthCreateUsers < ActiveRecord::Migration[4.2]
|
6
|
+
def change
|
7
|
+
create_table(:users) do |t|
|
8
|
+
## Database authenticatable
|
9
|
+
t.string :email
|
10
|
+
t.string :encrypted_password, null: false, default: ''
|
11
|
+
|
12
|
+
## Recoverable
|
13
|
+
t.string :reset_password_token
|
14
|
+
t.datetime :reset_password_sent_at
|
15
|
+
t.string :reset_password_redirect_url
|
16
|
+
t.boolean :allow_password_change, default: false
|
17
|
+
|
18
|
+
## Rememberable
|
19
|
+
t.datetime :remember_created_at
|
20
|
+
|
21
|
+
## Trackable
|
22
|
+
t.integer :sign_in_count, default: 0, null: false
|
23
|
+
t.datetime :current_sign_in_at
|
24
|
+
t.datetime :last_sign_in_at
|
25
|
+
t.string :current_sign_in_ip
|
26
|
+
t.string :last_sign_in_ip
|
27
|
+
|
28
|
+
## Confirmable
|
29
|
+
t.string :confirmation_token
|
30
|
+
t.datetime :confirmed_at
|
31
|
+
t.datetime :confirmation_sent_at
|
32
|
+
t.string :unconfirmed_email # Only if using reconfirmable
|
33
|
+
|
34
|
+
## Lockable
|
35
|
+
# t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
|
36
|
+
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
37
|
+
# t.datetime :locked_at
|
38
|
+
|
39
|
+
## User Info
|
40
|
+
t.string :name
|
41
|
+
t.string :nickname
|
42
|
+
t.string :image
|
43
|
+
|
44
|
+
## unique oauth id
|
45
|
+
t.string :provider
|
46
|
+
t.string :uid, null: false, default: ''
|
47
|
+
|
48
|
+
## Tokens
|
49
|
+
if json_supported_database?
|
50
|
+
t.json :tokens
|
51
|
+
else
|
52
|
+
t.text :tokens
|
53
|
+
end
|
54
|
+
|
55
|
+
t.timestamps
|
56
|
+
end
|
57
|
+
|
58
|
+
add_index :users, :email
|
59
|
+
add_index :users, [:uid, :provider], unique: true
|
60
|
+
add_index :users, :reset_password_token, unique: true
|
61
|
+
add_index :users, :confirmation_token, unique: true
|
62
|
+
add_index :users, :nickname, unique: true
|
63
|
+
# add_index :users, :unlock_token, :unique => true
|
64
|
+
end
|
65
|
+
end
|