diff options
| author | Alban Peignier | 2016-05-13 20:03:57 +0200 |
|---|---|---|
| committer | Alban Peignier | 2016-05-13 20:04:26 +0200 |
| commit | f5a3f0061fed4f8f51ebc0d556539a483626f76e (patch) | |
| tree | bf967831e62c6e4acb0dbd1901271dad31925608 | |
| parent | 48c8997c649fa183923164714ea916c4e6976727 (diff) | |
| download | chouette-core-f5a3f0061fed4f8f51ebc0d556539a483626f76e.tar.bz2 | |
Make configurable User authentication via config.chouette_authentication_settings. Refs #816
| -rw-r--r-- | app/models/user.rb | 6 | ||||
| -rw-r--r-- | config/environments/development.rb | 12 | ||||
| -rw-r--r-- | config/environments/test.rb | 8 | ||||
| -rw-r--r-- | config/initializers/devise.rb | 12 |
4 files changed, 22 insertions, 16 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 019249699..475e7629c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,9 +1,13 @@ class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable, :database_authenticatable + + @@authentication_type = "#{Rails.application.config.chouette_authentication_settings[:type]}_authenticatable".to_sym + cattr_reader :authentication_type + devise :invitable, :registerable, :validatable, :recoverable, :rememberable, :trackable, - :confirmable, :async, :cas_authenticatable + :confirmable, :async, authentication_type # FIXME https://github.com/nbudin/devise_cas_authenticatable/issues/53 # Work around :validatable, when database_authenticatable is diabled. diff --git a/config/environments/development.rb b/config/environments/development.rb index 2d01ba666..336b3b700 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -57,11 +57,13 @@ Rails.application.configure do config.company_contact = "http://www.chouette.mobi/club-utilisateurs/contact-support/" config.accept_user_creation = true - # CITYWAY - # config.company_name = "cityway" - # config.company_theme = "#32adb0" - # config.company_contact = "http://www.cityway.fr/contact/?rub_code=14" - # config.accept_user_creation = false + config.chouette_authentication_settings = { + type: "database" + } + # config.chouette_authentication_settings = { + # type: "cas", + # cas_server: "http://stif-portail-dev.af83.priv/sessions" + # } # file to data for demo config.demo_data = "tmp/demo.zip" diff --git a/config/environments/test.rb b/config/environments/test.rb index 5fb3b1475..9db6ad9f3 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -46,11 +46,9 @@ Rails.application.configure do config.company_contact = "http://www.chouette.mobi/club-utilisateurs/contact-support/" config.accept_user_creation = true - # CITYWAY - # config.company_name = "cityway" - # config.company_theme = "#32adb0" - # config.company_contact = "http://www.cityway.fr/contact/?rub_code=14" - # config.accept_user_creation = false + config.chouette_authentication_settings = { + type: "database" + } # file to data for demo config.demo_data = "tmp/demo.zip" diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index aacc8ad0b..f8d12a0ee 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -5,7 +5,7 @@ Devise.setup do |config| # random tokens. Changing this key will render invalid all existing # confirmation, reset password and unlock tokens in the database. # config.secret_key = Rails.env.production? ? ENV['DEVISE_SECRET_KEY'] : 'e9b20cea45078c982c9cd42cc64c484071d582a3d366ad2b51f676d168bccb2e0fd20e87ebe64aff57ad7f8a1a1c50b76cb9dc4039c287a195f9621fdb557993' - + # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class @@ -95,7 +95,7 @@ Devise.setup do |config| # encryptor), the cost increases exponentially with the number of stretches (e.g. # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). config.stretches = Rails.env.test? ? 1 : 10 - + # Setup a pepper to generate the encrypted password. # config.pepper = "0420ef6a1b6b0ac63b9ac1e2b9624b411e331345a1bad99c85986f70aef62e9c7912955ea1616135224fc7c4ac319085a5e33831fb215a5e45043816746a2c2f" @@ -277,7 +277,9 @@ Devise.setup do |config| # so you need to do it manually. For the users scope, it would be: # config.omniauth_path_prefix = '/my_engine/users/auth' - config.cas_base_url = "http://stif-portail-dev.af83.priv/sessions" + if Rails.application.config.chouette_authentication_settings[:type] == "cas" + config.cas_base_url = Rails.application.config.chouette_authentication_settings[:cas_server] + end # you can override these if you need to, but cas_base_url is usually enough # config.cas_login_url = "https://cas.myorganization.com/login" @@ -330,6 +332,6 @@ Rails.application.config.to_prepare do Devise::RegistrationsController.layout proc{ |controller| ( action_name == "edit" || action_name == "update") ? "application" : "devise" } Devise::InvitationsController.layout proc{ |controller| ( action_name == "new") ? "application" : "devise" } Devise::ConfirmationsController.layout "devise" - Devise::UnlocksController.layout "devise" - Devise::PasswordsController.layout "devise" + Devise::UnlocksController.layout "devise" + Devise::PasswordsController.layout "devise" end |
