contour 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +16 -6
- data/README.rdoc +38 -36
- data/Rakefile +1 -1
- data/app/controllers/contour/authentications_controller.rb +0 -10
- data/app/controllers/contour/registrations_controller.rb +8 -8
- data/app/controllers/contour/sessions_controller.rb +4 -4
- data/app/models/authentication.rb +1 -1
- data/app/views/contour/authentications/index.html.erb +3 -3
- data/app/views/contour/layouts/_latest_news.html.erb +4 -4
- data/app/views/contour/layouts/_menu.html.erb +3 -3
- data/app/views/contour/layouts/application.html.erb +8 -8
- data/app/views/contour/passwords/edit.html.erb +2 -2
- data/app/views/contour/passwords/new.html.erb +3 -3
- data/app/views/contour/registrations/edit.html.erb +2 -2
- data/app/views/contour/registrations/new.html.erb +4 -4
- data/app/views/contour/sessions/new.html.erb +4 -4
- data/contour.gemspec +6 -6
- data/lib/contour/fixes/omniauth.rb +22 -29
- data/lib/contour/fixes/rack.rb +2 -33
- data/lib/contour/version.rb +1 -1
- data/test/dummy/app/models/user.rb +9 -9
- data/test/dummy/config/initializers/devise.rb +122 -49
- data/test/dummy/config/routes.rb +8 -8
- data/test/dummy/db/migrate/{20111203203123_create_users.rb → 20111203203123_devise_create_users.rb} +9 -6
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +3464 -0
- metadata +27 -31
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -5
@@ -1,10 +1,10 @@
|
|
1
1
|
<% @title = 'Forgot your password?' %>
|
2
2
|
|
3
|
-
<%= form_for(resource, :
|
3
|
+
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
<fieldset style="width:235px">
|
6
6
|
<legend><%= @title %></legend>
|
7
|
-
|
7
|
+
|
8
8
|
<div class="field">
|
9
9
|
<%= f.label :email %><br />
|
10
10
|
<%= f.text_field :email %>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
</fieldset>
|
13
13
|
<div class="actions">
|
14
14
|
<% form_name = "new_#{resource.class.name.underscore}" %>
|
15
|
-
<%= link_to_function image_tag('contour/tick.png', :
|
15
|
+
<%= link_to_function image_tag('contour/tick.png', alt: '') + "Send me reset password instructions", "$('##{form_name}').submit();", class: "button positive" %>
|
16
16
|
<div style="clear:both"></div><br />
|
17
17
|
<%= link_to "Login here!", new_session_path(resource_name) %> or <%= link_to "Register here!", new_registration_path(resource_name) %>
|
18
18
|
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
2
2
|
|
3
|
-
<%= form_for(resource, :
|
3
|
+
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
|
6
6
|
<p><%= f.label :email %><br />
|
@@ -20,6 +20,6 @@
|
|
20
20
|
|
21
21
|
<h3>Cancel my account</h3>
|
22
22
|
|
23
|
-
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :
|
23
|
+
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), confirm: "Are you sure?", method: :delete %>.</p>
|
24
24
|
|
25
25
|
<%= link_to "Back", :back %>
|
@@ -1,17 +1,17 @@
|
|
1
1
|
<% @title = 'Register' %>
|
2
2
|
|
3
|
-
<%= form_for(resource, :
|
3
|
+
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
<fieldset style="width:235px">
|
6
6
|
<legend><%= @title %></legend>
|
7
|
-
|
7
|
+
|
8
8
|
<% if resource.methods.include?(:first_name) %>
|
9
9
|
<div class="field">
|
10
10
|
<%= f.label :first_name %><br />
|
11
11
|
<%= f.text_field :first_name %>
|
12
12
|
</div>
|
13
13
|
<% end %>
|
14
|
-
|
14
|
+
|
15
15
|
<% if resource.methods.include?(:last_name) %>
|
16
16
|
<div class="field">
|
17
17
|
<%= f.label :last_name %><br />
|
@@ -38,7 +38,7 @@
|
|
38
38
|
</fieldset>
|
39
39
|
<div class="actions">
|
40
40
|
<% form_name = "new_#{resource.class.name.underscore}" %>
|
41
|
-
<%= link_to_function image_tag('contour/tick.png', :
|
41
|
+
<%= link_to_function image_tag('contour/tick.png', alt: '') + "Sign up", "$('##{form_name}').submit();", class: "button positive" %>
|
42
42
|
<div style="clear:both"></div><br />
|
43
43
|
<%= link_to "Already signed up? Login here!", new_session_path(resource_name) %>
|
44
44
|
</div>
|
@@ -3,10 +3,10 @@
|
|
3
3
|
<table class="blank padded">
|
4
4
|
<tr>
|
5
5
|
<td style="vertical-align:top">
|
6
|
-
<%= form_for(resource, :
|
6
|
+
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
|
7
7
|
<fieldset style="width:235px">
|
8
8
|
<legend><%= @title %></legend>
|
9
|
-
|
9
|
+
|
10
10
|
<div class="field">
|
11
11
|
<%= f.label :email %><br />
|
12
12
|
<%= f.text_field :email %>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
</fieldset>
|
19
19
|
<div class="actions">
|
20
20
|
<% form_name = "new_#{resource.class.name.underscore}" %>
|
21
|
-
<%= link_to_function image_tag('contour/tick.png', :
|
21
|
+
<%= link_to_function image_tag('contour/tick.png', alt: '') + "Login", "$('##{form_name}').submit();", class: "button positive" %>
|
22
22
|
<% if devise_mapping.rememberable? -%>
|
23
23
|
<div style="padding-top:5px;padding-bottom:4px;"><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
|
24
24
|
<% end -%>
|
@@ -30,7 +30,7 @@
|
|
30
30
|
<% end %>
|
31
31
|
</td>
|
32
32
|
<td style="vertical-align:top">
|
33
|
-
<%= render :
|
33
|
+
<%= render partial: 'contour/layouts/latest_news' %>
|
34
34
|
</td>
|
35
35
|
</tr>
|
36
36
|
</table>
|
data/contour.gemspec
CHANGED
@@ -17,20 +17,20 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.homepage = 'https://github.com/remomueller'
|
18
18
|
s.summary = 'Basic Rails framework files and assets for layout and authentication'
|
19
19
|
s.description = 'Basic Rails Framework files and assets for layout and authentication'
|
20
|
-
|
20
|
+
|
21
21
|
s.platform = Gem::Platform::RUBY
|
22
|
-
|
23
|
-
s.add_dependency 'rails', '~> 3.2.0
|
22
|
+
|
23
|
+
s.add_dependency 'rails', '~> 3.2.0'
|
24
24
|
s.add_dependency 'jquery-rails', '~> 2.0.0'
|
25
|
-
s.add_dependency 'devise', '~> 1.5.3'
|
26
|
-
s.add_dependency 'omniauth', '~> 1.0.
|
25
|
+
s.add_dependency 'devise', '~> 2.0.0.rc' #'~> 1.5.3'
|
26
|
+
s.add_dependency 'omniauth', '~> 1.0.2'
|
27
27
|
s.add_dependency 'omniauth-openid', '~> 1.0.1'
|
28
28
|
s.add_dependency 'omniauth-ldap', '~> 1.0.2'
|
29
29
|
s.add_dependency 'omniauth-twitter', '~> 0.0.7'
|
30
30
|
s.add_dependency 'omniauth-facebook', '~> 1.2.0'
|
31
31
|
s.add_dependency 'omniauth-linkedin', '~> 0.0.6'
|
32
32
|
s.add_dependency 'omniauth-cas', '~> 0.0.3'
|
33
|
-
|
33
|
+
|
34
34
|
s.files = Dir["{app,config,db,lib}/**/*"] + ["CHANGELOG.rdoc", "contour.gemspec", "LICENSE", "Rakefile", "README.rdoc"]
|
35
35
|
s.test_files = Dir["test/**/*"]
|
36
36
|
end
|
@@ -2,6 +2,8 @@ require 'omniauth'
|
|
2
2
|
require 'omniauth-ldap'
|
3
3
|
|
4
4
|
# Overwriting methods from Rack
|
5
|
+
# While OmniAuth 1.0.2 fixes the Builder setup, Rack 1.4.0 still responds incorrectly to it's release version.
|
6
|
+
# Wait for Rack 1.4.1 or updated version before removing the Builder fixes
|
5
7
|
module OmniAuth
|
6
8
|
|
7
9
|
# class Builder updates for Rack 1.4.0
|
@@ -10,15 +12,15 @@ module OmniAuth
|
|
10
12
|
@use, @map, @run = [], nil, app
|
11
13
|
instance_eval(&block) if block_given?
|
12
14
|
end
|
13
|
-
|
15
|
+
|
14
16
|
def on_failure(&block)
|
15
17
|
OmniAuth.config.on_failure = block
|
16
18
|
end
|
17
|
-
|
19
|
+
|
18
20
|
def configure(&block)
|
19
21
|
OmniAuth.configure(&block)
|
20
22
|
end
|
21
|
-
|
23
|
+
|
22
24
|
def provider(klass, *args, &block)
|
23
25
|
if klass.is_a?(Class)
|
24
26
|
middleware = klass
|
@@ -29,10 +31,10 @@ module OmniAuth
|
|
29
31
|
raise LoadError, "Could not find matching strategy for #{klass.inspect}. You may need to install an additional gem (such as omniauth-#{klass})."
|
30
32
|
end
|
31
33
|
end
|
32
|
-
|
34
|
+
|
33
35
|
use middleware, *args, &block
|
34
36
|
end
|
35
|
-
|
37
|
+
|
36
38
|
def call(env)
|
37
39
|
to_app.call(env)
|
38
40
|
end
|
@@ -41,13 +43,8 @@ end
|
|
41
43
|
|
42
44
|
# Fix for LDAP Authentication with Domains
|
43
45
|
module OmniAuth
|
44
|
-
|
45
|
-
|
46
|
-
@html << "<input type='hidden' id='#{name}' name='#{name}' value='#{value}'/>"
|
47
|
-
self
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
46
|
+
|
47
|
+
# Required to correctly authenticate given bind_dn and LDAP
|
51
48
|
module LDAP
|
52
49
|
class Adaptor
|
53
50
|
class LdapError < StandardError; end
|
@@ -64,7 +61,7 @@ module OmniAuth
|
|
64
61
|
end
|
65
62
|
raise ArgumentError.new(message.join(",") +" MUST be provided") unless message.empty?
|
66
63
|
end
|
67
|
-
|
64
|
+
|
68
65
|
def bind_as(args = {})
|
69
66
|
result = false
|
70
67
|
ldap = @connection
|
@@ -73,43 +70,39 @@ module OmniAuth
|
|
73
70
|
result = rs.first if rs
|
74
71
|
result
|
75
72
|
end
|
76
|
-
|
73
|
+
|
77
74
|
end
|
78
75
|
end
|
79
76
|
|
77
|
+
# Required for proper script name for suburis
|
78
|
+
# Required for appending domain option to user credentials
|
80
79
|
module Strategies
|
81
80
|
class LDAP
|
82
81
|
include OmniAuth::Strategy
|
83
|
-
|
82
|
+
|
84
83
|
option :domain, ''
|
85
|
-
|
84
|
+
|
86
85
|
def request_phase
|
87
86
|
OmniAuth::LDAP::Adaptor.validate @options
|
88
|
-
f = OmniAuth::Form.new(:
|
89
|
-
f.hidden_field 'domain', options[:domain] # Added to allow domains from option
|
87
|
+
f = OmniAuth::Form.new( title: (options[:title] || "LDAP Authentication"), url: "#{@env['SCRIPT_NAME']}" + callback_path ) # Modified to include @env['SCRIPT_NAME']
|
90
88
|
f.text_field 'Login', 'username'
|
91
89
|
f.password_field 'Password', 'password'
|
90
|
+
f.button "Sign In"
|
92
91
|
f.to_response
|
93
92
|
end
|
94
|
-
|
93
|
+
|
95
94
|
def callback_phase
|
96
|
-
|
97
|
-
bind_dn = "#{request['domain'] + '\\' unless request['domain'].blank?}#{request['username']}" # Added
|
95
|
+
bind_dn = "#{@options[:domain] + '\\' unless @options[:domain].blank?}#{request['username']}" # Added
|
98
96
|
@options[:bind_dn] = bind_dn if @options[:bind_dn].blank? # Added
|
99
97
|
@adaptor = OmniAuth::LDAP::Adaptor.new @options
|
100
|
-
|
101
98
|
raise MissingCredentialsError.new("Missing login credentials") if request['username'].nil? || request['password'].nil?
|
102
99
|
begin
|
103
|
-
@ldap_user_info = @adaptor.bind_as(base: @adaptor.base, username: bind_dn, :
|
104
|
-
|
105
|
-
# return fail!(:invalid_credentials) if !@ldap_user_info
|
106
|
-
return redirect failure_temp_path if !@ldap_user_info
|
107
|
-
|
100
|
+
@ldap_user_info = @adaptor.bind_as(base: @adaptor.base, username: bind_dn, password: request['password']) # Modified
|
101
|
+
return fail!(:invalid_credentials) if !@ldap_user_info
|
108
102
|
@user_info = self.class.map_user(@@config, @ldap_user_info)
|
109
103
|
super
|
110
104
|
rescue Exception => e
|
111
|
-
|
112
|
-
return redirect failure_temp_path
|
105
|
+
return fail!(:ldap_error, e)
|
113
106
|
end
|
114
107
|
end
|
115
108
|
end
|
data/lib/contour/fixes/rack.rb
CHANGED
@@ -1,27 +1,10 @@
|
|
1
1
|
# Overwriting methods from Rack
|
2
2
|
module Rack
|
3
3
|
class Request
|
4
|
-
def scheme
|
5
|
-
# Rails.logger.debug "Contour::Fixes => Rack::Request::scheme"
|
6
|
-
if @env['HTTPS'] == 'on'
|
7
|
-
'https'
|
8
|
-
elsif @env['HTTP_X_FORWARDED_SSL'] == 'on'
|
9
|
-
'https'
|
10
|
-
elsif @env['HTTP_X_FORWARDED_PROTO']
|
11
|
-
@env['HTTP_X_FORWARDED_PROTO'].split(',')[0]
|
12
|
-
else
|
13
|
-
@env["rack.url_scheme"]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def ssl?
|
18
|
-
scheme == 'https'
|
19
|
-
end
|
20
|
-
|
21
4
|
def host_with_port
|
22
5
|
if forwarded = @env["HTTP_X_FORWARDED_HOST"]
|
23
|
-
Rails.logger.info "\n\nContour::Fixes
|
24
|
-
Rails.logger.info "@env[HTTP_X_FORWARDED_HOST]: #{@env["HTTP_X_FORWARDED_HOST"]} USING
|
6
|
+
Rails.logger.info "\n\nContour::Fixes Rack::Request::host_with_port"
|
7
|
+
Rails.logger.info "@env[HTTP_X_FORWARDED_HOST]: #{@env["HTTP_X_FORWARDED_HOST"]} USING: #{forwarded.split(/,\s?/).first}\n\n"
|
25
8
|
# forwarded.split(/,\s?/).last
|
26
9
|
# changed forwarded to first since we don't want the internal IP.
|
27
10
|
forwarded.split(/,\s?/).first
|
@@ -29,19 +12,5 @@ module Rack
|
|
29
12
|
@env['HTTP_HOST'] || "#{@env['SERVER_NAME'] || @env['SERVER_ADDR']}:#{@env['SERVER_PORT']}"
|
30
13
|
end
|
31
14
|
end
|
32
|
-
|
33
|
-
def port
|
34
|
-
if port = host_with_port.split(/:/)[1]
|
35
|
-
port.to_i
|
36
|
-
elsif port = @env['HTTP_X_FORWARDED_PORT']
|
37
|
-
port.to_i
|
38
|
-
elsif ssl?
|
39
|
-
443
|
40
|
-
elsif @env.has_key?("HTTP_X_FORWARDED_HOST")
|
41
|
-
80
|
42
|
-
else
|
43
|
-
@env["SERVER_PORT"].to_i
|
44
|
-
end
|
45
|
-
end
|
46
15
|
end
|
47
16
|
end
|
data/lib/contour/version.rb
CHANGED
@@ -11,35 +11,35 @@ class User < ActiveRecord::Base
|
|
11
11
|
attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name
|
12
12
|
|
13
13
|
# Named Scopes
|
14
|
-
scope :current, :
|
15
|
-
|
14
|
+
scope :current, conditions: { deleted: false }
|
15
|
+
|
16
16
|
# Model Relationships
|
17
17
|
has_many :authentications
|
18
|
-
|
18
|
+
|
19
19
|
def name
|
20
|
-
first_name
|
20
|
+
"#{first_name} #{last_name}"
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def reverse_name
|
24
|
-
last_name
|
24
|
+
"#{last_name}, #{first_name}"
|
25
25
|
end
|
26
26
|
|
27
27
|
# Overriding Devise built-in active? method
|
28
28
|
def active_for_authentication?
|
29
29
|
super and self.status == 'active' and not self.deleted?
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def apply_omniauth(omniauth)
|
33
33
|
unless omniauth['info'].blank?
|
34
34
|
self.email = omniauth['info']['email'] if email.blank?
|
35
35
|
self.first_name = omniauth['info']['first_name'] if first_name.blank?
|
36
36
|
self.last_name = omniauth['info']['last_name'] if last_name.blank?
|
37
37
|
end
|
38
|
-
authentications.build(:
|
38
|
+
authentications.build( provider: omniauth['provider'], uid: omniauth['uid'] )
|
39
39
|
end
|
40
40
|
|
41
41
|
def password_required?
|
42
42
|
(authentications.empty? || !password.blank?) && super
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
end
|
@@ -1,13 +1,17 @@
|
|
1
|
-
# Use this hook to configure devise mailer, warden hooks and so forth.
|
2
|
-
#
|
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
3
|
Devise.setup do |config|
|
4
4
|
# ==> Mailer Configuration
|
5
|
-
# Configure the e-mail address which will be shown in
|
6
|
-
|
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"
|
7
8
|
|
8
9
|
# Configure the class responsible to send e-mails.
|
9
10
|
# config.mailer = "Devise::Mailer"
|
10
11
|
|
12
|
+
# Automatically apply schema changes in tableless databases
|
13
|
+
config.apply_schema = false
|
14
|
+
|
11
15
|
# ==> ORM configuration
|
12
16
|
# Load and configure the ORM. Supports :active_record (default) and
|
13
17
|
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
@@ -15,68 +19,109 @@ Devise.setup do |config|
|
|
15
19
|
require 'devise/orm/active_record'
|
16
20
|
|
17
21
|
# ==> Configuration for any authentication mechanism
|
18
|
-
# Configure which keys are used when authenticating
|
22
|
+
# Configure which keys are used when authenticating a user. The default is
|
19
23
|
# just :email. You can configure it to use [:username, :subdomain], so for
|
20
|
-
# authenticating
|
24
|
+
# authenticating a user, both parameters are required. Remember that those
|
21
25
|
# parameters are used only when authenticating and not when retrieving from
|
22
26
|
# session. If you need permissions, you should implement that in a before filter.
|
27
|
+
# You can also supply a hash where the value is a boolean determining whether
|
28
|
+
# or not authentication should be aborted when the value is not present.
|
23
29
|
# config.authentication_keys = [ :email ]
|
24
30
|
|
31
|
+
# Configure parameters from the request object used for authentication. Each entry
|
32
|
+
# given should be a request method and it will automatically be passed to the
|
33
|
+
# find_for_authentication method and considered in your model lookup. For instance,
|
34
|
+
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
35
|
+
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
36
|
+
# config.request_keys = []
|
37
|
+
|
38
|
+
# Configure which authentication keys should be case-insensitive.
|
39
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
40
|
+
# to authenticate or find a user. Default is :email.
|
41
|
+
config.case_insensitive_keys = [ :email ]
|
42
|
+
|
43
|
+
# Configure which authentication keys should have whitespace stripped.
|
44
|
+
# These keys will have whitespace before and after removed upon creating or
|
45
|
+
# modifying a user and when used to authenticate or find a user. Default is :email.
|
46
|
+
config.strip_whitespace_keys = [ :email ]
|
47
|
+
|
25
48
|
# Tell if authentication through request.params is enabled. True by default.
|
26
49
|
# config.params_authenticatable = true
|
27
50
|
|
28
|
-
# Tell if authentication through HTTP Basic Auth is enabled.
|
51
|
+
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
|
29
52
|
config.http_authenticatable = true
|
30
53
|
|
31
|
-
#
|
54
|
+
# If http headers should be returned for AJAX requests. True by default.
|
32
55
|
# config.http_authenticatable_on_xhr = true
|
33
56
|
|
34
|
-
# The realm used in Http Basic Authentication
|
57
|
+
# The realm used in Http Basic Authentication. "Application" by default.
|
35
58
|
# config.http_authentication_realm = "Application"
|
36
59
|
|
60
|
+
# It will change confirmation, password recovery and other workflows
|
61
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
62
|
+
# Does not affect registerable.
|
63
|
+
# config.paranoid = true
|
64
|
+
|
65
|
+
# By default Devise will store the user in session. You can skip storage for
|
66
|
+
# :http_auth and :token_auth by adding those symbols to the array below.
|
67
|
+
config.skip_session_storage = [:http_auth]
|
68
|
+
|
37
69
|
# ==> Configuration for :database_authenticatable
|
38
70
|
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
39
71
|
# using other encryptors, it sets how many times you want the password re-encrypted.
|
40
|
-
|
41
|
-
|
42
|
-
#
|
43
|
-
#
|
44
|
-
|
45
|
-
# (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
|
46
|
-
config.encryptor = :bcrypt
|
72
|
+
#
|
73
|
+
# Limiting the stretches to just one in testing will increase the performance of
|
74
|
+
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
75
|
+
# a value less than 10 in other environments.
|
76
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
47
77
|
|
48
78
|
# Setup a pepper to generate the encrypted password.
|
49
79
|
config.pepper = "d142367154e5beacca404b1a6a4f8bc52c6fdcfa3ccc3cf8eb49f3458a688ee6ac3b9fae488432a3bfca863b8a90008368a9f3a3dfbe5a962e64b6ab8f3a3a1a"
|
50
80
|
|
51
|
-
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
|
81
|
+
# ==> Configuration for :confirmable
|
82
|
+
# A period that the user is allowed to access the website even without
|
83
|
+
# confirming his account. For instance, if set to 2.days, the user will be
|
84
|
+
# able to access the website for two days without confirming his account,
|
85
|
+
# access will be blocked just in the third day. Default is 0.days, meaning
|
86
|
+
# the user cannot access the website without confirming his account.
|
87
|
+
# config.allow_unconfirmed_access_for = 2.days
|
88
|
+
|
89
|
+
# If true, requires any email changes to be confirmed (exctly the same way as
|
90
|
+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
91
|
+
# db field (see migrations). Until confirmed new email is stored in
|
92
|
+
# unconfirmed email column, and copied to email column on successful confirmation.
|
93
|
+
config.reconfirmable = true
|
94
|
+
|
95
|
+
# Defines which key will be used when confirming an account
|
96
|
+
# config.confirmation_keys = [ :email ]
|
59
97
|
|
60
98
|
# ==> Configuration for :rememberable
|
61
99
|
# The time the user will be remembered without asking for credentials again.
|
62
100
|
# config.remember_for = 2.weeks
|
63
101
|
|
64
|
-
# If true, a valid remember token can be re-used between multiple browsers.
|
65
|
-
# config.remember_across_browsers = true
|
66
|
-
|
67
102
|
# If true, extends the user's remember period when remembered via cookie.
|
68
103
|
# config.extend_remember_period = false
|
69
104
|
|
105
|
+
# If true, uses the password salt as remember token. This should be turned
|
106
|
+
# to false if you are not using database authenticatable.
|
107
|
+
config.use_salt_as_remember_token = true
|
108
|
+
|
109
|
+
# Options to be passed to the created cookie. For instance, you can set
|
110
|
+
# :secure => true in order to force SSL only cookies.
|
111
|
+
# config.cookie_options = {}
|
112
|
+
|
70
113
|
# ==> Configuration for :validatable
|
71
|
-
# Range for password length
|
72
|
-
# config.password_length = 6..
|
114
|
+
# Range for password length. Default is 6..128.
|
115
|
+
# config.password_length = 6..128
|
73
116
|
|
74
|
-
#
|
75
|
-
#
|
117
|
+
# Email regex used to validate email formats. It simply asserts that
|
118
|
+
# an one (and only one) @ exists in the given string. This is mainly
|
119
|
+
# to give user feedback and not to assert the e-mail validity.
|
120
|
+
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
76
121
|
|
77
122
|
# ==> Configuration for :timeoutable
|
78
123
|
# The time you want to timeout the user session without activity. After this
|
79
|
-
# time the user will be asked for credentials again.
|
124
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
80
125
|
config.timeout_in = 8.hours
|
81
126
|
|
82
127
|
# ==> Configuration for :lockable
|
@@ -85,6 +130,9 @@ Devise.setup do |config|
|
|
85
130
|
# :none = No lock strategy. You should handle locking by yourself.
|
86
131
|
# config.lock_strategy = :failed_attempts
|
87
132
|
|
133
|
+
# Defines which key will be used when locking and unlocking an account
|
134
|
+
# config.unlock_keys = [ :email ]
|
135
|
+
|
88
136
|
# Defines which strategy will be used to unlock an account.
|
89
137
|
# :email = Sends an unlock link to the user email
|
90
138
|
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
@@ -99,6 +147,24 @@ Devise.setup do |config|
|
|
99
147
|
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
100
148
|
# config.unlock_in = 1.hour
|
101
149
|
|
150
|
+
# ==> Configuration for :recoverable
|
151
|
+
#
|
152
|
+
# Defines which key will be used when recovering the password for an account
|
153
|
+
# config.reset_password_keys = [ :email ]
|
154
|
+
|
155
|
+
# Time interval you can reset your password with a reset password key.
|
156
|
+
# Don't put a too small interval or your users won't have the time to
|
157
|
+
# change their passwords.
|
158
|
+
config.reset_password_within = 6.hours
|
159
|
+
|
160
|
+
# ==> Configuration for :encryptable
|
161
|
+
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
162
|
+
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
163
|
+
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
164
|
+
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
165
|
+
# REST_AUTH_SITE_KEY to pepper)
|
166
|
+
# config.encryptor = :sha512
|
167
|
+
|
102
168
|
# ==> Configuration for :token_authenticatable
|
103
169
|
# Defines name of the authentication token params key
|
104
170
|
# config.token_authentication_key = :auth_token
|
@@ -107,36 +173,43 @@ Devise.setup do |config|
|
|
107
173
|
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
108
174
|
# "users/sessions/new". It's turned off by default because it's slower if you
|
109
175
|
# are using only default views.
|
110
|
-
# config.scoped_views =
|
176
|
+
# config.scoped_views = false
|
111
177
|
|
112
178
|
# Configure the default scope given to Warden. By default it's the first
|
113
|
-
# devise role declared in your routes.
|
179
|
+
# devise role declared in your routes (usually :user).
|
114
180
|
# config.default_scope = :user
|
115
181
|
|
116
|
-
# Configure sign_out behavior.
|
117
|
-
#
|
118
|
-
#
|
119
|
-
# config.sign_out_all_scopes =
|
182
|
+
# Configure sign_out behavior.
|
183
|
+
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
|
184
|
+
# The default is true, which means any logout action will sign out all active scopes.
|
185
|
+
# config.sign_out_all_scopes = true
|
120
186
|
|
121
187
|
# ==> Navigation configuration
|
122
188
|
# Lists the formats that should be treated as navigational. Formats like
|
123
189
|
# :html, should redirect to the sign in page when the user does not have
|
124
190
|
# access, but formats like :xml or :json, should return 401.
|
191
|
+
#
|
125
192
|
# If you have any extra navigational formats, like :iphone or :mobile, you
|
126
|
-
# should add them to the navigational formats lists.
|
127
|
-
#
|
193
|
+
# should add them to the navigational formats lists.
|
194
|
+
#
|
195
|
+
# The :"*/*" and "*/*" formats below is required to match Internet
|
196
|
+
# Explorer requests.
|
197
|
+
# config.navigational_formats = [:"*/*", "*/*", :html]
|
198
|
+
|
199
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
200
|
+
config.sign_out_via = :get
|
201
|
+
|
202
|
+
# ==> OmniAuth
|
203
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
204
|
+
# up on your models and hooks.
|
205
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
128
206
|
|
129
207
|
# ==> Warden configuration
|
130
|
-
# If you want to use other strategies, that are not
|
131
|
-
# you can configure them inside the config.warden block.
|
132
|
-
# allows you to setup OAuth, using http://github.com/roman/warden_oauth
|
208
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
209
|
+
# change the failure app, you can configure them inside the config.warden block.
|
133
210
|
#
|
134
211
|
# config.warden do |manager|
|
135
|
-
# manager.
|
136
|
-
#
|
137
|
-
# twitter.consumer_key = <YOUR CONSUMER KEY>
|
138
|
-
# twitter.options :site => 'http://twitter.com'
|
139
|
-
# end
|
140
|
-
# manager.default_strategies(:scope => :user).unshift :twitter_oauth
|
212
|
+
# manager.intercept_401 = false
|
213
|
+
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
141
214
|
# end
|
142
215
|
end
|