bpluser 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +16 -0
  5. data/app/assets/javascripts/bpluser/application.js +15 -0
  6. data/app/assets/stylesheets/bpluser/application.css +13 -0
  7. data/app/controllers/bpluser/application_controller.rb +4 -0
  8. data/app/controllers/bpluser/registrations_controller.rb +0 -0
  9. data/app/controllers/bpluser/users/omniauth_callbacks_controller.rb +56 -0
  10. data/app/controllers/bpluser/users/registrations_controller.rb +30 -0
  11. data/app/controllers/bpluser/users/sessions_controller.rb +23 -0
  12. data/app/helpers/bpluser/application_helper.rb +4 -0
  13. data/app/models/bpluser/ability.rb +19 -0
  14. data/app/models/bpluser/folder.rb +21 -0
  15. data/app/models/bpluser/folder_item.rb +15 -0
  16. data/app/models/bpluser/user.rb +196 -0
  17. data/app/models/bpluser/user_institution.rb +6 -0
  18. data/app/views/layouts/bpluser/application.html.erb +14 -0
  19. data/config/routes.rb +2 -0
  20. data/lib/bpluser.rb +9 -0
  21. data/lib/bpluser/engine.rb +5 -0
  22. data/lib/bpluser/routes.rb +37 -0
  23. data/lib/bpluser/version.rb +3 -0
  24. data/lib/generators/bpluser/bpluser_generator.rb +183 -0
  25. data/lib/generators/bpluser/templates/config/hydra-ldap.yml +33 -0
  26. data/lib/generators/bpluser/templates/config/initializers/devise.rb +252 -0
  27. data/lib/generators/bpluser/templates/config/omniauth-facebook.yml +14 -0
  28. data/lib/generators/bpluser/templates/config/omniauth-polaris.yml +20 -0
  29. data/lib/generators/bpluser/templates/controllers/users/omniauth_callbacks_controller.rb +3 -0
  30. data/lib/generators/bpluser/templates/controllers/users/registrations_controller.rb +3 -0
  31. data/lib/generators/bpluser/templates/controllers/users/sessions_controller.rb +3 -0
  32. data/lib/generators/bpluser/templates/migrations/add_fields_to_user.rb +22 -0
  33. data/lib/generators/bpluser/templates/migrations/add_folder_items_to_folder.rb +18 -0
  34. data/lib/generators/bpluser/templates/migrations/add_folders_to_user.rb +14 -0
  35. data/lib/generators/bpluser/templates/migrations/create_institutions_for_users.rb +16 -0
  36. data/lib/generators/bpluser/templates/models/ability.rb +4 -0
  37. data/lib/generators/bpluser/templates/models/user.rb +14 -0
  38. data/lib/generators/bpluser/templates/views/devise/registrations/edit.html.erb +0 -0
  39. data/lib/generators/bpluser/templates/views/devise/registrations/new.html.erb +24 -0
  40. data/lib/generators/bpluser/templates/views/devise/sessions/new.html.erb +17 -0
  41. data/lib/tasks/bpluser_tasks.rake +10 -0
  42. data/test/bpluser_test.rb +7 -0
  43. data/test/dummy/README.rdoc +261 -0
  44. data/test/dummy/Rakefile +7 -0
  45. data/test/dummy/app/assets/javascripts/application.js +15 -0
  46. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  47. data/test/dummy/app/controllers/application_controller.rb +3 -0
  48. data/test/dummy/app/helpers/application_helper.rb +2 -0
  49. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  50. data/test/dummy/config.ru +4 -0
  51. data/test/dummy/config/application.rb +59 -0
  52. data/test/dummy/config/boot.rb +10 -0
  53. data/test/dummy/config/environment.rb +5 -0
  54. data/test/dummy/config/environments/development.rb +37 -0
  55. data/test/dummy/config/environments/production.rb +67 -0
  56. data/test/dummy/config/environments/test.rb +37 -0
  57. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  58. data/test/dummy/config/initializers/inflections.rb +15 -0
  59. data/test/dummy/config/initializers/mime_types.rb +5 -0
  60. data/test/dummy/config/initializers/secret_token.rb +7 -0
  61. data/test/dummy/config/initializers/session_store.rb +8 -0
  62. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  63. data/test/dummy/config/locales/en.yml +5 -0
  64. data/test/dummy/config/routes.rb +4 -0
  65. data/test/dummy/public/404.html +26 -0
  66. data/test/dummy/public/422.html +26 -0
  67. data/test/dummy/public/500.html +25 -0
  68. data/test/dummy/public/favicon.ico +0 -0
  69. data/test/dummy/script/rails +6 -0
  70. data/test/integration/navigation_test.rb +10 -0
  71. data/test/test_helper.rb +15 -0
  72. metadata +241 -0
@@ -0,0 +1,6 @@
1
+ module Bpluser
2
+ class UserInstitution < ActiveRecord::Base
3
+ self.table_name = "user_institutions"
4
+ belongs_to :user
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Bpluser</title>
5
+ <%= stylesheet_link_tag "bpluser/application", :media => "all" %>
6
+ <%= javascript_include_tag "bpluser/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Bpluser::Engine.routes.draw do
2
+ end
data/lib/bpluser.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "bpluser/engine"
2
+
3
+ module Bpluser
4
+ autoload :Routes, 'bpluser/routes'
5
+
6
+ def self.add_routes(router, options = {})
7
+ Bpluser::Routes.new(router, options).draw
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Bpluser
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Bpluser
4
+ end
5
+ end
@@ -0,0 +1,37 @@
1
+ module Bpluser
2
+ class Routes
3
+ def initialize(router, options)
4
+ @router = router
5
+ @options = options
6
+ end
7
+
8
+ def draw
9
+ route_sets.each do |r|
10
+ self.send(r)
11
+ end
12
+ end
13
+
14
+ protected
15
+
16
+ def add_routes &blk
17
+ @router.instance_exec(@options, &blk)
18
+ end
19
+
20
+ def route_sets
21
+ (@options[:only] || default_route_sets) - (@options[:except] || [])
22
+ end
23
+
24
+ def default_route_sets
25
+ [:omniauth_callbacks]
26
+ end
27
+
28
+ module RouteSets
29
+ def omniauth_callbacks
30
+ add_routes do |options|
31
+ resources :omniauth_callbacks
32
+ end
33
+ end
34
+ end
35
+ include RouteSets
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module Bpluser
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,183 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+
5
+ class BpluserGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ argument :model_name, :type => :string , :default => "user"
11
+ class_option :devise , :type => :boolean, :default => false, :aliases => "-d", :desc => "Use Devise as authentication logic (this is default)."
12
+ class_option :role_management , :type => :boolean, :default => true, :aliases => "-r", :desc => "Use Hydra Role Management as authentication logic (this is default)."
13
+ class_option :institution_management , :type => :boolean, :default => true, :aliases => "-i", :desc => "Use BPL Institution Management as authentication logic (this is default)."
14
+
15
+ desc """
16
+ This generator makes the following changes to your application:
17
+ 1. List here
18
+
19
+ Thank you for Installing BPLUser.
20
+ """
21
+
22
+ # Implement the required interface for Rails::Generators::Migration.
23
+ # taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
24
+ def self.next_migration_number(path)
25
+ unless @prev_migration_nr
26
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
27
+ else
28
+ @prev_migration_nr += 1
29
+ end
30
+ @prev_migration_nr.to_s
31
+ end
32
+
33
+ def check_arguments
34
+ #if File.exists?("app/models/#{model_name}.rb") and options[:devise]
35
+ #puts "Because you have selected \"#{model_name}\", which is an existing class, you will need to install devise manually and then run this generator without the Devise option. You can find additional information here: https://github.com/plataformatec/devise. \n Please be sure to include a to_s method in #{model_name} that returns the users name or email, as this will be used by Blacklight to provide a link to user specific information."
36
+ #exit
37
+ #end
38
+ end
39
+
40
+ # Install Devise?
41
+ def generate_devise_assets
42
+ if options[:devise]
43
+ if Rails::VERSION::MAJOR == 4
44
+ gem "devise", github:'plataformatec/devise', branch: 'rails4'
45
+ else
46
+ gem "devise"
47
+ end
48
+
49
+ gem "devise-guests", "~> 0.3"
50
+
51
+ Bundler.with_clean_env do
52
+ run "bundle install"
53
+ end
54
+
55
+ generate "devise:install"
56
+ generate "devise", model_name.classify
57
+ generate "devise_guests", model_name.classify
58
+ generate "devise:views"
59
+
60
+ end
61
+ end
62
+
63
+
64
+ #Add gem dependenceies
65
+ def add_the_gems
66
+ gem 'omniauth'
67
+ gem 'omniauth-ldap'
68
+ gem 'omniauth-facebook'
69
+ gem 'omniauth-polaris', :git => 'https://github.com/boston-library/omniauth-polaris.git'
70
+ gem 'omniauth-password'
71
+ gem 'bootstrap_forms'
72
+ Bundler.with_clean_env do
73
+ run "bundle install"
74
+ end
75
+ end
76
+
77
+
78
+ # Copy all files in templates/config directory to host config
79
+ def create_configuration_files
80
+ copy_file "config/initializers/devise.rb", "config/initializers/devise.rb"
81
+ copy_file "controllers/users/omniauth_callbacks_controller.rb", "app/controllers/users/omniauth_callbacks_controller.rb"
82
+ copy_file "controllers/users/registrations_controller.rb", "app/controllers/users/registrations_controller.rb"
83
+ copy_file "controllers/users/sessions_controller.rb", "app/controllers/users/sessions_controller.rb"
84
+ copy_file "models/user.rb", "app/models/user.rb"
85
+ copy_file "models/ability.rb", "app/models/ability.rb"
86
+ copy_file "views/devise/registrations/new.html.erb", "app/views/devise/registrations/new.html.erb"
87
+ copy_file "views/devise/registrations/edit.html.erb", "app/views/devise/registrations/edit.html.erb"
88
+ copy_file "views/devise/sessions/new.html.erb", "app/views/devise/sessions/new.html.erb"
89
+
90
+ if !File.exists?("config/hydra-ldap.yml")
91
+ copy_file "config/hydra-ldap.yml", "config/hydra-ldap.yml"
92
+ end
93
+
94
+ if !File.exists?("config/omniauth-polaris.yml")
95
+ copy_file "config/omniauth-polaris.yml", "config/omniauth-polaris.yml"
96
+ end
97
+
98
+ if !File.exists?("config/omniauth-facebook.yml")
99
+ copy_file "config/omniauth-facebook.yml", "config/omniauth-facebook.yml"
100
+ end
101
+
102
+ end
103
+
104
+ # Setup the database migrations
105
+ def copy_migrations
106
+ # Can't get this any more DRY, because we need this order.
107
+ better_migration_template "add_fields_to_user.rb"
108
+ better_migration_template "add_folders_to_user.rb"
109
+ better_migration_template "add_folder_items_to_folder.rb"
110
+ #better_migration_template "create_institutions_for_users.rb"
111
+ end
112
+
113
+
114
+ # Install Hydra Role Management?
115
+ def generate_hydra_role_management
116
+ if options[:role_management]
117
+ if Rails::VERSION::MAJOR == 4
118
+ #gem "devise", github:'plataformatec/devise', branch: 'rails4'
119
+ else
120
+ gem "hydra-role-management"
121
+ end
122
+
123
+ Bundler.with_clean_env do
124
+ run "bundle install"
125
+ end
126
+
127
+ generate "roles"
128
+
129
+ Bundler.with_clean_env do
130
+ run "bundle install"
131
+ end
132
+ end
133
+ end
134
+
135
+ # Install BPL Institution management?
136
+ def generate_bpl_institution_management
137
+ if options[:institution_management]
138
+ if Rails::VERSION::MAJOR == 4
139
+ #gem "devise", github:'plataformatec/devise', branch: 'rails4'
140
+ else
141
+ gem 'bpl-institution-management', :git => 'https://github.com/boston-library/bpl-institution-management.git'
142
+ end
143
+
144
+ Bundler.with_clean_env do
145
+ run "bundle install"
146
+ end
147
+
148
+ generate "institutions"
149
+
150
+ Bundler.with_clean_env do
151
+ run "bundle install"
152
+ end
153
+ end
154
+ end
155
+
156
+
157
+ def inject_bpluser_routes
158
+ # These will end up in routes.rb file in reverse order
159
+ # we add em, since each is added at the top of file.
160
+ # we want "root" to be FIRST for optimal url generation.
161
+ #route('devise_for :users, :controllers => { :omniauth_callbacks => "bpluser/users/omniauth_callbacks" }')
162
+ gsub_file("config/routes.rb", "devise_for :users", "")
163
+ route('devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks", :registrations => "users/registrations", :sessions => "users/sessions"}')
164
+ route('mount Bpluser::Engine => "/bpluser"')
165
+ route('Bpluser.add_routes(self)')
166
+ end
167
+
168
+
169
+ private
170
+
171
+ def better_migration_template (file)
172
+ begin
173
+ migration_template "migrations/#{file}", "db/migrate/#{file}"
174
+ sleep 1 # ensure scripts have different time stamps
175
+ rescue
176
+ puts " \e[1m\e[34mMigrations\e[0m " + $!.message
177
+ end
178
+ end
179
+
180
+
181
+
182
+
183
+ end
@@ -0,0 +1,33 @@
1
+ test:
2
+ host: #######.bpl.org
3
+ port: 389
4
+ #group_base: nil
5
+ base: dc=bpl,dc=org
6
+ uid: #######
7
+ username: #####
8
+ password: #####
9
+ admin_base: dc=bpl,dc=org
10
+
11
+ development:
12
+ host: #######.bpl.org
13
+ port: 389
14
+ #group_base: nil
15
+ base: dc=bpl,dc=org
16
+ uid: #######
17
+ username: #####
18
+ password: #####
19
+ group_member: uniquemember # attribute name in a group to identify a member
20
+ group_owner: owner # attribute name to identify group owner
21
+ admin_base: dc=bpl,dc=org
22
+
23
+ production:
24
+ host: #######.bpl.org
25
+ port: 389
26
+ #group_base: nil
27
+ base: dc=bpl,dc=org
28
+ uid: #######
29
+ username: #####
30
+ password: #####
31
+ group_member: uniquemember # attribute name in a group to identify a member
32
+ group_owner: owner # attribute name to identify group owner
33
+ admin_base: dc=bpl,dc=org
@@ -0,0 +1,252 @@
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 = [ :uid, :provider ]
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 = [ :uid, :provider ]
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 = [ :uid, :provider ]
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 = "9f1215eee7c0a54ea396a8127aa2b80279e6d60d7df395f39d01ea32db6e073c9617d18c098817a3a60bda550f07feab9ceed36d2f66c9294725d74b3c8b645d"
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 = :get
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
+ config.omniauth :ldap, :title => 'BPL admin ldap',
210
+ :host => Hydra::LDAP.ldap_config[:host],
211
+ :base => Hydra::LDAP.ldap_config[:base],
212
+ :uid => Hydra::LDAP.ldap_config[:uid],
213
+ :port => Hydra::LDAP.ldap_config[:port],
214
+ :bind_dn => Hydra::LDAP.ldap_config[:username],
215
+ :password => Hydra::LDAP.ldap_config[:password]
216
+
217
+ config.omniauth :password, :title => 'BPL local account login',
218
+ :login_field => :username
219
+
220
+ OMNIAUTH_POLARIS_GLOBAL = YAML.load_file(Rails.root.join('config', 'omniauth-polaris.yml'))[Rails.env]
221
+ config.omniauth :polaris, :title => OMNIAUTH_POLARIS_GLOBAL['title'],
222
+ :http_uri => OMNIAUTH_POLARIS_GLOBAL['http_uri'],
223
+ :access_key => OMNIAUTH_POLARIS_GLOBAL['access_key'],
224
+ :access_id => OMNIAUTH_POLARIS_GLOBAL['access_id'],
225
+ :method => OMNIAUTH_POLARIS_GLOBAL['method']
226
+
227
+ OMNIAUTH_FACEBOOK_GLOBAL = YAML.load_file(Rails.root.join('config', 'omniauth-facebook.yml'))[Rails.env]
228
+ config.omniauth :facebook, OMNIAUTH_FACEBOOK_GLOBAL['facebook_key'], OMNIAUTH_FACEBOOK_GLOBAL['facebook_secret'], :scope=>OMNIAUTH_FACEBOOK_GLOBAL['facebook_scope']
229
+
230
+ # ==> Warden configuration
231
+ # If you want to use other strategies, that are not supported by Devise, or
232
+ # change the failure app, you can configure them inside the config.warden block.
233
+ #
234
+ # config.warden do |manager|
235
+ # manager.intercept_401 = false
236
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
237
+ # end
238
+
239
+ # ==> Mountable engine configurations
240
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
241
+ # is mountable, there are some extra configurations to be taken into account.
242
+ # The following options are available, assuming the engine is mounted as:
243
+ #
244
+ # mount MyEngine, at: "/my_engine"
245
+ #
246
+ # The router that invoked `devise_for`, in the example above, would be:
247
+ # config.router_name = :my_engine
248
+ #
249
+ # When using omniauth, Devise cannot automatically set Omniauth path,
250
+ # so you need to do it manually. For the users scope, it would be:
251
+ # config.omniauth_path_prefix = "/my_engine/users/auth"
252
+ end