mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 13:52:50 +08:00
commit
4ff6780758
1
Gemfile
1
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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
#
|
||||
|
|
@ -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'
|
||||
|
|
|
@ -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)"
|
||||
|
|
|
@ -482,7 +482,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 <a href="/admin/site_settings">the Site Settings</a> and update the settings. <a href="https://github.com/discourse/discourse/wiki/The-Discourse-Admin-Quick-Start-Guide#enable-facebook-logins" target="_blank">See this guide to learn more</a>.'
|
||||
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 <a href="/admin/site_settings">the Site Settings</a> and update the settings. <a href="https://github.com/discourse/discourse/wiki/The-Discourse-Admin-Quick-Start-Guide#enable-twitter-logins" target="_blank">See this guide to learn more</a>.'
|
||||
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 <a href="/admin/site_settings">the Site Settings</a> and update the settings. <a href="https://github.com/discourse/discourse/wiki/The-Discourse-Admin-Quick-Start-Guide" target="_blank">See this guide to learn more</a>.'
|
||||
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 <a href="/admin/site_settings">the Site Settings</a> and update the settings. <a href="http://meta.discourse.org/t/how-to-set-up-image-uploads-to-s3/7229" target="_blank">See "How to set up image uploads to S3?" to learn more</a>.'
|
||||
|
@ -675,10 +674,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"
|
||||
|
|
|
@ -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
|
||||
|
|
36
db/migrate/20140211230222_move_cas_settings.rb
Normal file
36
db/migrate/20140211230222_move_cas_settings.rb
Normal file
|
@ -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
|
|
@ -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'
|
||||
|
|
|
@ -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
|
|
@ -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!"
|
||||
|
|
|
@ -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) }
|
||||
|
|
Loading…
Reference in New Issue
Block a user