From 34f9e17eac48b13117fd3398bbd4f1ce71cfb894 Mon Sep 17 00:00:00 2001 From: Erik Ordway Date: Tue, 11 Feb 2014 15:53:54 -0800 Subject: [PATCH 1/6] Allow plugins to specify the value used for require statements. This allows using forked gems in plugins until the original gem gets updated. --- lib/plugin/instance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index 8888a8cb339..27f274589b5 100644 --- a/lib/plugin/instance.rb +++ b/lib/plugin/instance.rb @@ -216,7 +216,7 @@ class Plugin::Instance spec = Gem::Specification.load spec_file spec.activate unless opts[:require] == false - require name + require opts[:require_name] ? opts[:require_name] : name end else puts "You are specifying the gem #{name} in #{path}, however it does not exist!" From f1e8bdaee54b16070ac97bbaf88f9f5bfff2f57a Mon Sep 17 00:00:00 2001 From: Erik Ordway Date: Tue, 11 Feb 2014 15:57:08 -0800 Subject: [PATCH 2/6] Remove cas auth from core and convert the settings over so they can be used by the plugin --- Gemfile | 1 - .../20140211230222_move_cas_settings.rb | 36 ++++++++++++++ lib/auth.rb | 1 - lib/auth/cas_authenticator.rb | 47 ------------------- 4 files changed, 36 insertions(+), 49 deletions(-) create mode 100644 db/migrate/20140211230222_move_cas_settings.rb delete mode 100644 lib/auth/cas_authenticator.rb diff --git a/Gemfile b/Gemfile index 9466727bd29..c87b63d9e87 100644 --- a/Gemfile +++ b/Gemfile @@ -114,7 +114,6 @@ gem 'omniauth-facebook' gem 'omniauth-twitter' gem 'omniauth-github' gem 'omniauth-oauth2', require: false -gem 'omniauth-cas' gem 'oj' # while resolving https://groups.google.com/forum/#!topic/ruby-pg/5_ylGmog1S4 gem 'pg', '0.15.1' diff --git a/db/migrate/20140211230222_move_cas_settings.rb b/db/migrate/20140211230222_move_cas_settings.rb new file mode 100644 index 00000000000..dc21545419c --- /dev/null +++ b/db/migrate/20140211230222_move_cas_settings.rb @@ -0,0 +1,36 @@ +class MoveCasSettings < ActiveRecord::Migration + def change + #As part of removing the build in CAS authentication we should + #convert the data over to be used by the plugin. + cas_hostname = SiteSetting.where(name: 'cas_hostname').first + cas_sso_hostname = SiteSetting.where(name: 'cas_sso_hostname').first + if cas_hostname && ! cas_sso_hostname + #convert the setting over for use by the plugin + cas_hostname.update_attribute(:name, 'cas_sso_hostname') + elsif cas_hostname && cas_sso_hostname + #copy the setting over for use by the plugin and delete the original setting + cas_sso_hostname.update_attribute(:value,cas_hostname.value) + cas_hostname.destroy + end + + cas_domainname = SiteSetting.where(name: 'cas_domainname').first + cas_sso_email_domain = SiteSetting.where(name: 'cas_sso_email_domain').first + if cas_domainname && ! cas_sso_email_domain + #convert the setting over for use by the plugin + cas_domainname.update_attribute(:name, 'cas_sso_email_domain') + elsif cas_domainname && cas_sso_email_domain + #copy the setting over for use by the plugin and delete the original setting + cas_sso_email_domain.update_attribute(:value,cas_domainname.value) + cas_domainname.destroy + end + + cas_logins = SiteSetting.where(name: 'cas_logins').first + if cas_logins + cas_logins.destroy + end + + #remove the unused table + drop_table :cas_user_infos + + end +end diff --git a/lib/auth.rb b/lib/auth.rb index 10a8bd272de..3acb5891a12 100644 --- a/lib/auth.rb +++ b/lib/auth.rb @@ -6,4 +6,3 @@ require_dependency 'auth/facebook_authenticator' require_dependency 'auth/open_id_authenticator' require_dependency 'auth/github_authenticator' require_dependency 'auth/twitter_authenticator' -require_dependency 'auth/cas_authenticator' diff --git a/lib/auth/cas_authenticator.rb b/lib/auth/cas_authenticator.rb deleted file mode 100644 index 3c9fc4f46ec..00000000000 --- a/lib/auth/cas_authenticator.rb +++ /dev/null @@ -1,47 +0,0 @@ -class Auth::CasAuthenticator < Auth::Authenticator - - def name - 'cas' - end - - def after_authenticate(auth_token) - result = Auth::Result.new - - email = auth_token[:info][:email] if auth_token[:info] - email ||= if SiteSetting.cas_domainname.present? - "#{auth_token[:extra][:user]}@#{SiteSetting.cas_domainname}" - else - auth_token[:extra][:user] - end - - result.email = email - result.email_valid = true - - result.username = username = auth_token[:extra][:user] - - result.name = name = if auth_token[:info] && auth_token[:info][:name] - auth_token[:info][:name] - else - auth_token["uid"] - end - - cas_user_id = auth_token["uid"] - - result.extra_data = { - cas_user_id: cas_user_id - } - - user_info = CasUserInfo.where(:cas_user_id => cas_user_id ).first - - result.user = user_info.try(:user) - result.user ||= User.where(email: email).first - # TODO, create CAS record ? - - result - end - - def register_middleware(omniauth) - omniauth.provider :cas, - :host => SiteSetting.cas_hostname - end -end From 1167b5c4b5da0bab8d0e69b8a33200cca98dc08a Mon Sep 17 00:00:00 2001 From: Erik Ordway Date: Tue, 11 Feb 2014 17:25:54 -0800 Subject: [PATCH 3/6] I can see this on git hub but it is being missing by the test --- app/controllers/users/omniauth_callbacks_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index b00b3578960..ad5c2be4db4 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -10,8 +10,7 @@ class Users::OmniauthCallbacksController < ApplicationController Auth::OpenIdAuthenticator.new("google", "https://www.google.com/accounts/o8/id", trusted: true), Auth::OpenIdAuthenticator.new("yahoo", "https://me.yahoo.com", trusted: true), Auth::GithubAuthenticator.new, - Auth::TwitterAuthenticator.new, - Auth::CasAuthenticator.new + Auth::TwitterAuthenticator.new ] skip_before_filter :redirect_to_login_if_required From 557d1886bbf3b9403d51ee6c01b1aa4ab1c3847c Mon Sep 17 00:00:00 2001 From: Erik Ordway Date: Tue, 11 Feb 2014 17:53:20 -0800 Subject: [PATCH 4/6] remove what little CAS testing there was. --- spec/models/user_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 8a6b2e4251e..656a8791d9a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -24,7 +24,6 @@ describe User do it { should have_one(:facebook_user_info).dependent(:destroy) } it { should have_one(:twitter_user_info).dependent(:destroy) } it { should have_one(:github_user_info).dependent(:destroy) } - it { should have_one(:cas_user_info).dependent(:destroy) } it { should have_one(:oauth2_user_info).dependent(:destroy) } it { should have_one(:user_stat).dependent(:destroy) } it { should belong_to(:approved_by) } From 8fc5c66c55253468078416d6b7f6d0d2f0b19405 Mon Sep 17 00:00:00 2001 From: Erik Ordway Date: Tue, 11 Feb 2014 18:13:24 -0800 Subject: [PATCH 5/6] this needs to go but did not show up in my tests but did on travis --- app/models/cas_user_info.rb | 27 --------------------------- app/models/user.rb | 1 - 2 files changed, 28 deletions(-) delete mode 100644 app/models/cas_user_info.rb diff --git a/app/models/cas_user_info.rb b/app/models/cas_user_info.rb deleted file mode 100644 index 2366e3e3dab..00000000000 --- a/app/models/cas_user_info.rb +++ /dev/null @@ -1,27 +0,0 @@ -class CasUserInfo < ActiveRecord::Base - belongs_to :user -end - -# == Schema Information -# -# Table name: cas_user_infos -# -# id :integer not null, primary key -# user_id :integer not null -# cas_user_id :string(255) not null -# username :string(255) not null -# first_name :string(255) -# last_name :string(255) -# email :string(255) -# gender :string(255) -# name :string(255) -# link :string(255) -# created_at :datetime not null -# updated_at :datetime not null -# -# Indexes -# -# index_cas_user_infos_on_cas_user_id (cas_user_id) UNIQUE -# index_cas_user_infos_on_user_id (user_id) UNIQUE -# - diff --git a/app/models/user.rb b/app/models/user.rb index 540a320806f..3f06f1156a0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,7 +35,6 @@ class User < ActiveRecord::Base has_one :facebook_user_info, dependent: :destroy has_one :twitter_user_info, dependent: :destroy has_one :github_user_info, dependent: :destroy - has_one :cas_user_info, dependent: :destroy has_one :oauth2_user_info, dependent: :destroy has_one :user_stat, dependent: :destroy belongs_to :approved_by, class_name: 'User' From 98bac3b57dbc824604e51aaa4543b2ac3382f838 Mon Sep 17 00:00:00 2001 From: Erik Ordway Date: Wed, 12 Feb 2014 08:38:19 -0800 Subject: [PATCH 6/6] Purge settings and .en.yml translations. --- config/locales/client.en.yml | 3 --- config/locales/server.en.yml | 5 ----- config/site_settings.yml | 5 ----- 3 files changed, 13 deletions(-) diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index e94c3ffa066..5eb7de2b16a 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -478,9 +478,6 @@ en: facebook: title: "with Facebook" message: "Authenticating with Facebook (make sure pop up blockers are not enabled)" - cas: - title: "Log In with CAS" - message: "Authenticating with CAS (make sure pop up blockers are not enabled)" yahoo: title: "with Yahoo" message: "Authenticating with Yahoo (make sure pop up blockers are not enabled)" diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 0987b6a3f7f..c60e69f696e 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -466,7 +466,6 @@ en: queue_size_warning: 'The number of queued jobs is %{queue_size}, which is high. This could indicate a problem with the Sidekiq process(es), or you may need to add more Sidekiq workers.' memory_warning: 'Your server is running with less than 1 GB of total memory. At least 1 GB of memory is recommended.' facebook_config_warning: 'The server is configured to allow signup and log in with Facebook (enable_facebook_logins), but the app id and app secret values are not set. Go to the Site Settings and update the settings. See this guide to learn more.' - cas_config_warning: 'The server is configured to allow signup and log in with CAS (enable_cas_logins), but the hostname and domain name values are not set.' twitter_config_warning: 'The server is configured to allow signup and log in with Twitter (enable_twitter_logins), but the key and secret values are not set. Go to the Site Settings and update the settings. See this guide to learn more.' github_config_warning: 'The server is configured to allow signup and log in with GitHub (enable_github_logins), but the client id and secret values are not set. Go to the Site Settings and update the settings. See this guide to learn more.' s3_config_warning: 'The server is configured to upload files to s3, but at least one the following setting is not set: s3_access_key_id, s3_secret_access_key or s3_upload_bucket. Go to the Site Settings and update the settings. See "How to set up image uploads to S3?" to learn more.' @@ -659,10 +658,6 @@ en: facebook_app_id: "App id for Facebook authentication, registered at https://developers.facebook.com/apps" facebook_app_secret: "App secret for Facebook authentication, registered at https://developers.facebook.com/apps" - enable_cas_logins: "Enable CAS authentication" - cas_hostname: "Hostname for cas server" - cas_domainname: "Domain name generated email addresses for cas server" - enable_github_logins: "Enable Github authentication, requires github_client_id and github_client_secret" github_client_id: "Client id for Github authentication, registered at https://github.com/settings/applications" github_client_secret: "Client secret for Github authentication, registered at https://github.com/settings/applications" diff --git a/config/site_settings.yml b/config/site_settings.yml index eed6fa01e35..33c6190b1e2 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -103,11 +103,6 @@ users: default: true facebook_app_id: '' facebook_app_secret: '' - enable_cas_logins: - client: true - default: false - cas_hostname: '' - cas_domainname: '' enable_github_logins: client: true default: false