DEV: Drop legacy OpenID 2.0 support (#8894)

This is not used in core or official plugins, and has been printing a deprecation notice since v2.3.0beta4. All OpenID 2.0 code and dependencies have been dropped. The user_open_ids table remains for now, in case anyone has missed the deprecation notice, and needs to migrate their data.

Context at https://meta.discourse.org/t/-/113249
This commit is contained in:
David Taylor
2020-02-07 17:32:35 +00:00
committed by GitHub
parent e3c3c88ab5
commit 5919618a87
16 changed files with 12 additions and 203 deletions

View File

@@ -1,56 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe Auth::OpenIdAuthenticator do
it "can lookup pre-existing user if trusted" do
auth = Auth::OpenIdAuthenticator.new("test", "id", "enable_yahoo_logins", trusted: true)
user = Fabricate(:user)
response = OpenStruct.new(identity_url: 'abc')
result = auth.after_authenticate(info: { email: user.email }, extra: { response: response })
expect(result.user).to eq(user)
end
it "raises an exception when email is missing" do
auth = Auth::OpenIdAuthenticator.new("test", "id", "enable_yahoo_logins", trusted: true)
response = OpenStruct.new(identity_url: 'abc')
expect { auth.after_authenticate(info: {}, extra: { response: response }) }.to raise_error(Discourse::InvalidParameters)
end
it 'can connect to a different existing user account' do
authenticator = Auth::OpenIdAuthenticator.new("test", "id", "enable_yahoo_logins", trusted: true)
user1 = Fabricate(:user)
user2 = Fabricate(:user)
UserOpenId.create!(url: "id/123" , user_id: user1.id, email: "bob@example.com", active: true)
hash = {
info: { email: user1.email }, extra: { response: OpenStruct.new(identity_url: 'id/123') }
}
result = authenticator.after_authenticate(hash, existing_account: user2)
expect(result.user.id).to eq(user2.id)
expect(UserOpenId.exists?(user_id: user1.id)).to eq(false)
expect(UserOpenId.exists?(user_id: user2.id)).to eq(true)
end
context 'revoke' do
fab!(:user) { Fabricate(:user) }
let(:authenticator) { Auth::OpenIdAuthenticator.new("test", "id", "enable_yahoo_logins", trusted: true) }
it 'raises exception if no entry for user' do
expect { authenticator.revoke(user) }.to raise_error(Discourse::NotFound)
end
it 'revokes correctly' do
UserOpenId.create!(url: "id/123" , user_id: user.id, email: "bob@example.com", active: true)
expect(authenticator.can_revoke?).to eq(true)
expect(authenticator.revoke(user)).to eq(true)
expect(authenticator.description_for_user(user)).to eq("")
end
end
end

View File

@@ -245,7 +245,7 @@ describe Plugin::Instance do
plugin.notify_before_auth
expect(DiscoursePluginRegistry.auth_providers.count).to eq(1)
auth_provider = DiscoursePluginRegistry.auth_providers.to_a[0]
expect(auth_provider.authenticator.name).to eq('ubuntu')
expect(auth_provider.authenticator.name).to eq('facebook')
end
it "finds all the custom assets" do

View File

@@ -6,7 +6,7 @@
# authors: Frank Zappa
auth_provider title: 'with Ubuntu',
authenticator: Auth::OpenIdAuthenticator.new('ubuntu', 'https://login.ubuntu.com', 'enable_badges', trusted: true),
authenticator: Auth::FacebookAuthenticator.new,
message: 'Authenticating with Ubuntu (make sure pop up blockers are not enbaled)',
frame_width: 1000, # the frame size used for the pop up window, overrides default
frame_height: 800

View File

@@ -1,10 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe UserOpenId do
it { is_expected.to belong_to :user }
it { is_expected.to validate_presence_of :email }
it { is_expected.to validate_presence_of :url }
end

View File

@@ -203,14 +203,12 @@ describe UserAnonymizer do
user.user_associated_accounts = [UserAssociatedAccount.create(user_id: user.id, provider_uid: "example", provider_name: "facebook")]
user.single_sign_on_record = SingleSignOnRecord.create(user_id: user.id, external_id: "example", last_payload: "looks good")
user.oauth2_user_infos = [Oauth2UserInfo.create(user_id: user.id, uid: "example", provider: "example")]
UserOpenId.create(user_id: user.id, email: user.email, url: "http://example.com/openid", active: true)
make_anonymous
user.reload
expect(user.github_user_info).to eq(nil)
expect(user.user_associated_accounts).to be_empty
expect(user.single_sign_on_record).to eq(nil)
expect(user.oauth2_user_infos).to be_empty
expect(user.user_open_ids.count).to eq(0)
end
it "removes api key" do

View File

@@ -994,7 +994,6 @@ describe UserMerger do
GithubUserInfo.create(user_id: source_user.id, screen_name: "example", github_user_id: "examplel123123")
Oauth2UserInfo.create(user_id: source_user.id, uid: "example", provider: "example")
SingleSignOnRecord.create(user_id: source_user.id, external_id: "example", last_payload: "looks good")
UserOpenId.create(user_id: source_user.id, email: source_user.email, url: "http://example.com/openid", active: true)
merge_users!
@@ -1002,7 +1001,6 @@ describe UserMerger do
expect(GithubUserInfo.where(user_id: source_user.id).count).to eq(0)
expect(Oauth2UserInfo.where(user_id: source_user.id).count).to eq(0)
expect(SingleSignOnRecord.where(user_id: source_user.id).count).to eq(0)
expect(UserOpenId.where(user_id: source_user.id).count).to eq(0)
end
it "deletes auth tokens" do