devise-multi-radius-authenticatable 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +7 -0
  5. data/Gemfile +3 -0
  6. data/MIT-LICENSE +21 -0
  7. data/README.md +85 -0
  8. data/Rakefile +16 -0
  9. data/devise-multi-radius-authenticatable.gemspec +32 -0
  10. data/lib/devise-radius-authenticatable.rb +8 -0
  11. data/lib/devise/models/radius_authenticatable.rb +187 -0
  12. data/lib/devise/radius_authenticatable.rb +45 -0
  13. data/lib/devise/radius_authenticatable/test_helpers.rb +126 -0
  14. data/lib/devise/radius_authenticatable/version.rb +5 -0
  15. data/lib/devise/strategies/radius_authenticatable.rb +30 -0
  16. data/lib/generators/devise_radius_authenticatable/install_generator.rb +93 -0
  17. data/spec/devise/models/radius_authenticatable_spec.rb +170 -0
  18. data/spec/factories/admins.rb +10 -0
  19. data/spec/fixtures/devise.rb +238 -0
  20. data/spec/generators/install_generator_spec.rb +66 -0
  21. data/spec/integration/radius_authenticatable_spec.rb +115 -0
  22. data/spec/rails_app/.gitignore +15 -0
  23. data/spec/rails_app/Gemfile +4 -0
  24. data/spec/rails_app/Rakefile +7 -0
  25. data/spec/rails_app/app/assets/images/rails.png +0 -0
  26. data/spec/rails_app/app/assets/javascripts/application.js +13 -0
  27. data/spec/rails_app/app/assets/stylesheets/application.css +13 -0
  28. data/spec/rails_app/app/controllers/admins_controller.rb +83 -0
  29. data/spec/rails_app/app/controllers/application_controller.rb +11 -0
  30. data/spec/rails_app/app/helpers/application_helper.rb +2 -0
  31. data/spec/rails_app/app/mailers/.gitkeep +0 -0
  32. data/spec/rails_app/app/models/.gitkeep +0 -0
  33. data/spec/rails_app/app/models/admin.rb +11 -0
  34. data/spec/rails_app/app/views/admins/_form.html.erb +17 -0
  35. data/spec/rails_app/app/views/admins/edit.html.erb +6 -0
  36. data/spec/rails_app/app/views/admins/index.html.erb +21 -0
  37. data/spec/rails_app/app/views/admins/new.html.erb +5 -0
  38. data/spec/rails_app/app/views/admins/show.html.erb +5 -0
  39. data/spec/rails_app/app/views/devise/confirmations/new.html.erb +12 -0
  40. data/spec/rails_app/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  41. data/spec/rails_app/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  42. data/spec/rails_app/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  43. data/spec/rails_app/app/views/devise/passwords/edit.html.erb +16 -0
  44. data/spec/rails_app/app/views/devise/passwords/new.html.erb +12 -0
  45. data/spec/rails_app/app/views/devise/registrations/edit.html.erb +29 -0
  46. data/spec/rails_app/app/views/devise/registrations/new.html.erb +18 -0
  47. data/spec/rails_app/app/views/devise/sessions/new.html.erb +17 -0
  48. data/spec/rails_app/app/views/devise/shared/_links.erb +25 -0
  49. data/spec/rails_app/app/views/devise/unlocks/new.html.erb +12 -0
  50. data/spec/rails_app/app/views/layouts/application.html.erb +25 -0
  51. data/spec/rails_app/bin/bundle +3 -0
  52. data/spec/rails_app/bin/rails +4 -0
  53. data/spec/rails_app/bin/rake +4 -0
  54. data/spec/rails_app/config.ru +4 -0
  55. data/spec/rails_app/config/application.rb +23 -0
  56. data/spec/rails_app/config/boot.rb +4 -0
  57. data/spec/rails_app/config/database.yml +25 -0
  58. data/spec/rails_app/config/environment.rb +5 -0
  59. data/spec/rails_app/config/environments/development.rb +29 -0
  60. data/spec/rails_app/config/environments/production.rb +80 -0
  61. data/spec/rails_app/config/environments/test.rb +36 -0
  62. data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  63. data/spec/rails_app/config/initializers/devise.rb +308 -0
  64. data/spec/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
  65. data/spec/rails_app/config/initializers/inflections.rb +16 -0
  66. data/spec/rails_app/config/initializers/mime_types.rb +5 -0
  67. data/spec/rails_app/config/initializers/secret_token.rb +12 -0
  68. data/spec/rails_app/config/initializers/session_store.rb +3 -0
  69. data/spec/rails_app/config/initializers/wrap_parameters.rb +14 -0
  70. data/spec/rails_app/config/locales/devise.en.yml +59 -0
  71. data/spec/rails_app/config/locales/en.yml +23 -0
  72. data/spec/rails_app/config/routes.rb +63 -0
  73. data/spec/rails_app/db/migrate/20120627042556_devise_create_admins.rb +48 -0
  74. data/spec/rails_app/db/schema.rb +37 -0
  75. data/spec/rails_app/db/seeds.rb +7 -0
  76. data/spec/rails_app/lib/assets/.gitkeep +0 -0
  77. data/spec/rails_app/lib/tasks/.gitkeep +0 -0
  78. data/spec/rails_app/public/404.html +26 -0
  79. data/spec/rails_app/public/422.html +26 -0
  80. data/spec/rails_app/public/500.html +25 -0
  81. data/spec/rails_app/public/favicon.ico +0 -0
  82. data/spec/rails_app/public/robots.txt +5 -0
  83. data/spec/rails_app/script/rails +6 -0
  84. data/spec/spec_helper.rb +28 -0
  85. data/spec/support/devise_helpers.rb +18 -0
  86. data/spec/support/generator_helpers.rb +16 -0
  87. metadata +359 -0
@@ -0,0 +1,5 @@
1
+ module Devise
2
+ module RadiusAuthenticatable
3
+ VERSION = "0.1.1".freeze
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ require 'devise/strategies/authenticatable'
2
+
3
+ module Devise
4
+ module Strategies
5
+ # Strategy for authenticating users with a radius server. If authentication with
6
+ # the radius server fails, allow warden to move on to the next strategy. When
7
+ # authentication succeeds and Devise indicates that the resource has been
8
+ # successfully validated, invoke the +after_radius_authentication+ callback on the
9
+ # resource and let warden know we were successful and not to continue with executing
10
+ # further strategies.
11
+ class RadiusAuthenticatable < Authenticatable
12
+ # Invoked by warden to execute the strategy.
13
+ def authenticate!
14
+ auth_params = authentication_hash.merge(password: password)
15
+
16
+ resource = valid_password? &&
17
+ mapping.to.find_for_radius_authentication(auth_params)
18
+
19
+ return fail(:invalid) unless resource
20
+
21
+ if validate(resource)
22
+ resource.after_radius_authentication
23
+ success!(resource)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ Warden::Strategies.add(:radius_authenticatable, Devise::Strategies::RadiusAuthenticatable)
@@ -0,0 +1,93 @@
1
+ module DeviseRadiusAuthenticatable
2
+ class InstallGenerator < Rails::Generators::Base
3
+ source_root File.expand_path("../../templates", __FILE__)
4
+
5
+ desc <<-DESC.gsub(/ {6}/, '')
6
+ Description:
7
+ Adds radius_authenticatable strategy to the devise initializer
8
+
9
+ <SERVER IP> - The IP address of the radius server
10
+ <SHARED SECRET> - The shared secret for the radius server
11
+ DESC
12
+
13
+ argument(:server, :banner => '<SERVER IP>',
14
+ :desc => 'The IP address of the radius server')
15
+ argument(:secret, :banner => '<SHARED SECRET>',
16
+ :desc => 'The shared secret for the radius server')
17
+ class_option(:uid_field, :default => :uid,
18
+ :desc => 'What database column to use for the UID')
19
+ class_option(:port, :default => 1812,
20
+ :desc => 'The port to connect to the radius server on')
21
+ class_option(:timeout, :default => 60,
22
+ :desc => 'How long to wait for a response from the radius server')
23
+ class_option(:retries, :default => 0,
24
+ :desc => 'How many times to retry a radius request')
25
+ class_option(:dictionary_path, :default => nil,
26
+ :desc => 'The path to load radius dictionary files from')
27
+ class_option(:handle_timeout_as_failure, :default => false,
28
+ :desc => 'Option to handle radius timeout as authentication failure')
29
+
30
+ def install
31
+ inject_into_file("config/initializers/devise.rb", default_devise_settings,
32
+ :before => /^\s*.*==> Scopes configuration/)
33
+ end
34
+
35
+ private
36
+
37
+ def default_devise_settings
38
+ <<-CONFIG.gsub(/ {6}/, '')
39
+
40
+ # ==> Configuration for radius_authenticatable
41
+ # The radius_authenticatable strategy can be used in place of the
42
+ # database_authenticatable strategy or alongside it. The default order of the
43
+ # strategies is the reverse of how they were loaded. You can control this
44
+ # order by explicitly telling warden the order in which to apply the strategies.
45
+ # See the Warden Configuration section for further details.
46
+ #
47
+ # Configure the hostname or IP address of the radius server to use.
48
+ config.radius_server = '#{server}'
49
+
50
+ # Configure the port to use when connecting to the radius server.
51
+ config.radius_server_port = #{options[:port]}
52
+
53
+ # Configure the shared secret needed to connect to the radius server.
54
+ config.radius_server_secret = '#{secret}'
55
+
56
+ # Configure the time in seconds to wait for a radius server to respond.
57
+ config.radius_server_timeout = #{options[:timeout]}
58
+
59
+ # Configure the number of times a request should be retried when a radius server
60
+ # does not immediately respond to requests.
61
+ config.radius_server_retries = #{options[:retries]}
62
+
63
+ # In some cases you may want to support authentication attempts against
64
+ # multiple radius servers. In these cases the same username could be used on
65
+ # each of the servers. In order to create unique database records, a unique
66
+ # username is generated by using the radius username and the radius server IP
67
+ # address once the authentication has succeeded. This configuration option
68
+ # allows you to chose which database column this calculated UID field will be
69
+ # stored in.
70
+ config.radius_uid_field = :#{options[:uid_field]}
71
+
72
+ # If you want to control how the unique identifier is created for each radius
73
+ # user, this can be customized by configuring a proc that accepts the username
74
+ # and the radius server as parameters and returns the uid.
75
+ #
76
+ # config.radius_uid_generator = Proc.new do |username, server|
77
+ # "\#{username}@\#{server}"
78
+ # end
79
+
80
+ # There is a very basic radius dictionary provided by default. Most of the time
81
+ # this will not be sufficient, so this configuration option allows you to
82
+ # specify the path that contains all of the radius dictionary files that should
83
+ # be loaded.
84
+ #
85
+ # config.radius_dictionary_path = '#{options[:dictionary_path]}'
86
+
87
+ # Option to handle radius timeout as authentication failure
88
+ #
89
+ config.handle_radius_timeout_as_failure = #{options[:handle_timeout_as_failure]}
90
+ CONFIG
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,170 @@
1
+ require 'spec_helper'
2
+
3
+ class Configurable < Admin
4
+ devise(:radius_authenticatable, :radius_server => '1.2.3.4',
5
+ :radius_server_port => 1813, :radius_server_secret => 'secret',
6
+ :radius_server_timeout => 120, :radius_server_retries => 3,
7
+ :radius_uid_field => :email,
8
+ :radius_uid_generator => Proc.new { |username, server|
9
+ "#{username}_#{server}"
10
+ },
11
+ :radius_dictionary_path => Rails.root.join('config/dictionaries'),
12
+ :handle_radius_timeout_as_failure => true)
13
+ end
14
+
15
+ describe Devise::Models::RadiusAuthenticatable do
16
+ let(:auth_key) { Devise.authentication_keys.first }
17
+
18
+ it "allows configuration of the radius server IP" do
19
+ Configurable.radius_server.should == '1.2.3.4'
20
+ end
21
+
22
+ it "allows configuration of the radius server port" do
23
+ Configurable.radius_server_port.should == 1813
24
+ end
25
+
26
+ it "allows configuration of the radius server shared secret" do
27
+ Configurable.radius_server_secret.should == 'secret'
28
+ end
29
+
30
+ it "allows configuration of the radius server timeout" do
31
+ Configurable.radius_server_timeout.should == 120
32
+ end
33
+
34
+ it "allows configuration of the radius server retries" do
35
+ Configurable.radius_server_retries.should == 3
36
+ end
37
+
38
+ it "allows configuration of the radius uid field" do
39
+ Configurable.radius_uid_field.should == :email
40
+ end
41
+
42
+ it "allows configuration of the radius uid generator" do
43
+ Configurable.radius_uid_generator.call('test', '1.2.3.4').should == 'test_1.2.3.4'
44
+ end
45
+
46
+ it "allows configuration of the radius dictionary path" do
47
+ Configurable.radius_dictionary_path.should == Rails.root.join('config/dictionaries')
48
+ end
49
+
50
+ it "allows configuration of the radius exception handling" do
51
+ Configurable.handle_radius_timeout_as_failure.should == true
52
+ end
53
+
54
+ it "extracts radius credentials based on the configured authentication keys" do
55
+ swap(Devise, :authentication_keys => [:username, :domain]) do
56
+ auth_hash = { :username => 'cbascom', :password => 'testing' }
57
+ Configurable.radius_credentials(auth_hash).should == ['cbascom', 'testing']
58
+ end
59
+ end
60
+
61
+ it "converts the username to lower case if the key is case insensitive" do
62
+ swap(Devise, {:authentication_keys => [:username, :domain],
63
+ :case_insensitive_keys => [:username]}) do
64
+ auth_hash = { :username => 'Cbascom', :password => 'testing' }
65
+ Configurable.radius_credentials(auth_hash).should == ['cbascom', 'testing']
66
+ end
67
+ end
68
+
69
+ it "does not convert the username to lower case if the key is not case insensitive" do
70
+ swap(Devise, {:authentication_keys => [:username, :domain],
71
+ :case_insensitive_keys => []}) do
72
+ auth_hash = { :username => 'Cbascom', :password => 'testing' }
73
+ Configurable.radius_credentials(auth_hash).should == ['Cbascom', 'testing']
74
+ end
75
+ end
76
+
77
+ context "when finding the user record for authentication" do
78
+ let(:good_auth_hash) { {auth_key => 'testuser', :password => 'password'} }
79
+ let(:bad_auth_hash) { {auth_key => 'testuser', :password => 'wrongpassword'} }
80
+
81
+ before do
82
+ @uid_field = Admin.radius_uid_field.to_sym
83
+ @uid = Admin.radius_uid_generator.call('testuser', Admin.radius_server)
84
+ create_radius_user('testuser', 'password')
85
+ end
86
+
87
+ it "uses the generated uid and configured uid field to find the record" do
88
+ Admin.should_receive(:find_for_authentication).with(@uid_field => @uid)
89
+ Admin.find_for_radius_authentication(good_auth_hash)
90
+ end
91
+
92
+ context "and authentication succeeds" do
93
+ it "creates a new user record if none was found" do
94
+ Admin.find_for_radius_authentication(good_auth_hash).should be_new_record
95
+ end
96
+
97
+ it "fills in the uid when creating the new record" do
98
+ admin = Admin.find_for_radius_authentication(good_auth_hash)
99
+ admin.send(@uid_field).should == @uid
100
+ end
101
+
102
+ it "uses the existing user record when one is found" do
103
+ admin = FactoryGirl.create(:admin, @uid_field => @uid)
104
+ Admin.find_for_radius_authentication(good_auth_hash).should == admin
105
+ end
106
+ end
107
+
108
+ context "and authentication fails" do
109
+ it "does not create a new user record" do
110
+ Admin.find_for_radius_authentication(bad_auth_hash).should be_nil
111
+ end
112
+ end
113
+ end
114
+
115
+ context "when validating a radius user's password" do
116
+ before do
117
+ @admin = Admin.new
118
+ create_radius_user('testuser', 'password')
119
+ end
120
+
121
+ it "passes the configured options when building the radius request" do
122
+ server_url = "#{Admin.radius_server}:#{Admin.radius_server_port}"
123
+ @admin.valid_radius_password?('testuser', 'password')
124
+
125
+ radius_server.url.should == server_url
126
+ radius_server.options[:reply_timeout].should == Admin.radius_server_timeout
127
+ radius_server.options[:retries_number].should == Admin.radius_server_retries
128
+ radius_server.options[:dict].should be_a(Radiustar::Dictionary)
129
+ end
130
+
131
+ it "does not add the :dict option if no dictionary path is configured" do
132
+ swap(Admin, :radius_dictionary_path => nil) do
133
+ @admin.valid_radius_password?('testuser', 'password')
134
+ radius_server.options.should_not have_key(:dict)
135
+ end
136
+ end
137
+
138
+ it "returns false when the password is incorrect" do
139
+ @admin.valid_radius_password?('testuser', 'wrongpassword').should be_false
140
+ end
141
+
142
+ it "returns true when the password is correct" do
143
+ @admin.valid_radius_password?('testuser', 'password').should be_true
144
+ end
145
+
146
+ it "stores the returned attributes in the model" do
147
+ @admin.valid_radius_password?('testuser', 'password')
148
+ @admin.radius_attributes.should == radius_server.attributes('testuser')
149
+ end
150
+
151
+ context "when handle_radius_timeout_as_failure is false" do
152
+ it "does not catch the RuntimeError exception" do
153
+ Radiustar::Request.any_instance.stub(:authenticate).
154
+ and_raise(RuntimeError)
155
+ expect { @admin.valid_radius_password?('testuser', 'password') }.
156
+ to raise_error(RuntimeError)
157
+ end
158
+ end
159
+
160
+ context "when handle_radius_timeout_as_failure is true" do
161
+ it "returns false when the authentication times out" do
162
+ swap(Devise, :handle_radius_timeout_as_failure => true) do
163
+ Radiustar::Request.any_instance.stub(:authenticate).
164
+ and_raise(RuntimeError)
165
+ @admin.valid_radius_password?('testuser', 'password').should be_false
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+ sequence :admin_email do |n|
3
+ "admin#{n}@gmail.com"
4
+ end
5
+
6
+ factory :admin do
7
+ email { FactoryGirl.generate(:admin_email) }
8
+ password "password"
9
+ end
10
+ end
@@ -0,0 +1,238 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth.
2
+ # Many of these configuration options can be set straight in your model.
3
+ Devise.setup do |config|
4
+ # ==> Mailer Configuration
5
+ # Configure the e-mail address which will be shown in Devise::Mailer,
6
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
7
+ config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
8
+
9
+ # Configure the class responsible to send e-mails.
10
+ # config.mailer = "Devise::Mailer"
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/active_record'
17
+
18
+ # ==> Configuration for any authentication mechanism
19
+ # Configure which keys are used when authenticating a user. The default is
20
+ # just :email. You can configure it to use [:username, :subdomain], so for
21
+ # authenticating a user, both parameters are required. Remember that those
22
+ # parameters are used only when authenticating and not when retrieving from
23
+ # session. If you need permissions, you should implement that in a before filter.
24
+ # You can also supply a hash where the value is a boolean determining whether
25
+ # or not authentication should be aborted when the value is not present.
26
+ # config.authentication_keys = [ :email ]
27
+
28
+ # Configure parameters from the request object used for authentication. Each entry
29
+ # given should be a request method and it will automatically be passed to the
30
+ # find_for_authentication method and considered in your model lookup. For instance,
31
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
32
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
33
+ # config.request_keys = []
34
+
35
+ # Configure which authentication keys should be case-insensitive.
36
+ # These keys will be downcased upon creating or modifying a user and when used
37
+ # to authenticate or find a user. Default is :email.
38
+ config.case_insensitive_keys = [ :email ]
39
+
40
+ # Configure which authentication keys should have whitespace stripped.
41
+ # These keys will have whitespace before and after removed upon creating or
42
+ # modifying a user and when used to authenticate or find a user. Default is :email.
43
+ config.strip_whitespace_keys = [ :email ]
44
+
45
+ # Tell if authentication through request.params is enabled. True by default.
46
+ # It can be set to an array that will enable params authentication only for the
47
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
48
+ # enable it only for database (email + password) authentication.
49
+ # config.params_authenticatable = true
50
+
51
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
52
+ # It can be set to an array that will enable http authentication only for the
53
+ # given strategies, for example, `config.http_authenticatable = [:token]` will
54
+ # enable it only for token authentication.
55
+ # config.http_authenticatable = false
56
+
57
+ # If http headers should be returned for AJAX requests. True by default.
58
+ # config.http_authenticatable_on_xhr = true
59
+
60
+ # The realm used in Http Basic Authentication. "Application" by default.
61
+ # config.http_authentication_realm = "Application"
62
+
63
+ # It will change confirmation, password recovery and other workflows
64
+ # to behave the same regardless if the e-mail provided was right or wrong.
65
+ # Does not affect registerable.
66
+ # config.paranoid = true
67
+
68
+ # By default Devise will store the user in session. You can skip storage for
69
+ # :http_auth and :token_auth by adding those symbols to the array below.
70
+ # Notice that if you are skipping storage for all authentication paths, you
71
+ # may want to disable generating routes to Devise's sessions controller by
72
+ # passing :skip => :sessions to `devise_for` in your config/routes.rb
73
+ config.skip_session_storage = [:http_auth]
74
+
75
+ # ==> Configuration for :database_authenticatable
76
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
77
+ # using other encryptors, it sets how many times you want the password re-encrypted.
78
+ #
79
+ # Limiting the stretches to just one in testing will increase the performance of
80
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
81
+ # a value less than 10 in other environments.
82
+ config.stretches = Rails.env.test? ? 1 : 10
83
+
84
+ # Setup a pepper to generate the encrypted password.
85
+ # config.pepper = "f71add1f76d905b20d078ddc6b517eb3228ced6c75913835875b0379829892d52f79f79ace5f42df0aa299aa894186db070ccbe678bf575d7a081b515bcfde60"
86
+
87
+ # ==> Configuration for :confirmable
88
+ # A period that the user is allowed to access the website even without
89
+ # confirming his account. For instance, if set to 2.days, the user will be
90
+ # able to access the website for two days without confirming his account,
91
+ # access will be blocked just in the third day. Default is 0.days, meaning
92
+ # the user cannot access the website without confirming his account.
93
+ # config.allow_unconfirmed_access_for = 2.days
94
+
95
+ # If true, requires any email changes to be confirmed (exactly the same way as
96
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
97
+ # db field (see migrations). Until confirmed new email is stored in
98
+ # unconfirmed email column, and copied to email column on successful confirmation.
99
+ config.reconfirmable = true
100
+
101
+ # Defines which key will be used when confirming an account
102
+ # config.confirmation_keys = [ :email ]
103
+
104
+ # ==> Configuration for :rememberable
105
+ # The time the user will be remembered without asking for credentials again.
106
+ # config.remember_for = 2.weeks
107
+
108
+ # If true, extends the user's remember period when remembered via cookie.
109
+ # config.extend_remember_period = false
110
+
111
+ # Options to be passed to the created cookie. For instance, you can set
112
+ # :secure => true in order to force SSL only cookies.
113
+ # config.rememberable_options = {}
114
+
115
+ # ==> Configuration for :validatable
116
+ # Range for password length. Default is 6..128.
117
+ # config.password_length = 6..128
118
+
119
+ # Email regex used to validate email formats. It simply asserts that
120
+ # an one (and only one) @ exists in the given string. This is mainly
121
+ # to give user feedback and not to assert the e-mail validity.
122
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
123
+
124
+ # ==> Configuration for :timeoutable
125
+ # The time you want to timeout the user session without activity. After this
126
+ # time the user will be asked for credentials again. Default is 30 minutes.
127
+ # config.timeout_in = 30.minutes
128
+
129
+ # If true, expires auth token on session timeout.
130
+ # config.expire_auth_token_on_timeout = false
131
+
132
+ # ==> Configuration for :lockable
133
+ # Defines which strategy will be used to lock an account.
134
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
135
+ # :none = No lock strategy. You should handle locking by yourself.
136
+ # config.lock_strategy = :failed_attempts
137
+
138
+ # Defines which key will be used when locking and unlocking an account
139
+ # config.unlock_keys = [ :email ]
140
+
141
+ # Defines which strategy will be used to unlock an account.
142
+ # :email = Sends an unlock link to the user email
143
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
144
+ # :both = Enables both strategies
145
+ # :none = No unlock strategy. You should handle unlocking by yourself.
146
+ # config.unlock_strategy = :both
147
+
148
+ # Number of authentication tries before locking an account if lock_strategy
149
+ # is failed attempts.
150
+ # config.maximum_attempts = 20
151
+
152
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
153
+ # config.unlock_in = 1.hour
154
+
155
+ # ==> Configuration for :recoverable
156
+ #
157
+ # Defines which key will be used when recovering the password for an account
158
+ # config.reset_password_keys = [ :email ]
159
+
160
+ # Time interval you can reset your password with a reset password key.
161
+ # Don't put a too small interval or your users won't have the time to
162
+ # change their passwords.
163
+ config.reset_password_within = 6.hours
164
+
165
+ # ==> Configuration for :encryptable
166
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
167
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
168
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
169
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
170
+ # REST_AUTH_SITE_KEY to pepper)
171
+ # config.encryptor = :sha512
172
+
173
+ # ==> Configuration for :token_authenticatable
174
+ # Defines name of the authentication token params key
175
+ # config.token_authentication_key = :auth_token
176
+
177
+ # ==> Scopes configuration
178
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
179
+ # "users/sessions/new". It's turned off by default because it's slower if you
180
+ # are using only default views.
181
+ # config.scoped_views = false
182
+
183
+ # Configure the default scope given to Warden. By default it's the first
184
+ # devise role declared in your routes (usually :user).
185
+ # config.default_scope = :user
186
+
187
+ # Set this configuration to false if you want /users/sign_out to sign out
188
+ # only the current scope. By default, Devise signs out all scopes.
189
+ # config.sign_out_all_scopes = true
190
+
191
+ # ==> Navigation configuration
192
+ # Lists the formats that should be treated as navigational. Formats like
193
+ # :html, should redirect to the sign in page when the user does not have
194
+ # access, but formats like :xml or :json, should return 401.
195
+ #
196
+ # If you have any extra navigational formats, like :iphone or :mobile, you
197
+ # should add them to the navigational formats lists.
198
+ #
199
+ # The "*/*" below is required to match Internet Explorer requests.
200
+ # config.navigational_formats = ["*/*", :html]
201
+
202
+ # The default HTTP method used to sign out a resource. Default is :delete.
203
+ config.sign_out_via = :delete
204
+
205
+ # ==> OmniAuth
206
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
207
+ # up on your models and hooks.
208
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
209
+
210
+ # ==> Warden configuration
211
+ # If you want to use other strategies, that are not supported by Devise, or
212
+ # change the failure app, you can configure them inside the config.warden block.
213
+ #
214
+ # config.warden do |manager|
215
+ # manager.intercept_401 = false
216
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
217
+ # end
218
+ config.warden do |warden_config|
219
+ warden_config.default_strategies(:token_authenticatable,
220
+ :database_authenticatable,
221
+ :radius_authenticatable,
222
+ {:scope => :administrator})
223
+ end
224
+
225
+ # ==> Mountable engine configurations
226
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
227
+ # is mountable, there are some extra configurations to be taken into account.
228
+ # The following options are available, assuming the engine is mounted as:
229
+ #
230
+ # mount MyEngine, at: "/my_engine"
231
+ #
232
+ # The router that invoked `devise_for`, in the example above, would be:
233
+ # config.router_name = :my_engine
234
+ #
235
+ # When using omniauth, Devise cannot automatically set Omniauth path,
236
+ # so you need to do it manually. For the users scope, it would be:
237
+ # config.omniauth_path_prefix = "/my_engine/users/auth"
238
+ end