A platform for community discussion. Free, open, simple.
DEV: remove instagram login site settings and auth classes. (#11073)
Vinoth Kannan347423007a99
diff --git a/Gemfile b/Gemfileindex 68bb1a5ecf4..cb86d7e4bac 100644--- a/Gemfile+++ b/Gemfile@@ -101,7 +101,6 @@ gem 'css_parser', require: falsegem 'omniauth'gem 'omniauth-facebook'gem 'omniauth-twitter'-gem 'omniauth-instagram'gem 'omniauth-github'gem 'omniauth-oauth2', require: falsediff --git a/Gemfile.lock b/Gemfile.lockindex 4a5a6c3df71..1e557f2f823 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -226,9 +226,6 @@ GEMjwt (>= 2.0)omniauth (>= 1.1.1)omniauth-oauth2 (>= 1.6)- omniauth-instagram (1.3.0)- omniauth (~> 1)- omniauth-oauth2 (~> 1)omniauth-oauth (1.1.0)oauthomniauth (~> 1.0)@@ -504,7 +501,6 @@ DEPENDENCIESomniauth-facebookomniauth-githubomniauth-google-oauth2- omniauth-instagramomniauth-oauth2omniauth-twitteroneboxdiff --git a/app/assets/stylesheets/common/components/buttons.scss b/app/assets/stylesheets/common/components/buttons.scssindex 1355589694d..e00d5c2876d 100644--- a/app/assets/stylesheets/common/components/buttons.scss+++ b/app/assets/stylesheets/common/components/buttons.scss@@ -183,12 +183,6 @@background: var(--google-hover);}}- &.instagram {- background: var(--instagram);- &:hover {- background: var(--instagram-hover);- }- }&.facebook {background: $facebook;&:hover {diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 41b388b2510..608a288af52 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -1663,10 +1663,6 @@ en:twitter_consumer_key: "Consumer key for Twitter authentication, registered at <a href='https://developer.twitter.com/apps' target='_blank'>https://developer.twitter.com/apps</a>"twitter_consumer_secret: "Consumer secret for Twitter authentication, registered at <a href='https://developer.twitter.com/apps' target='_blank'>https://developer.twitter.com/apps</a>"- enable_instagram_logins: "Enable Instagram authentication, requires instagram_consumer_key and instagram_consumer_secret"- instagram_consumer_key: "Consumer key for Instagram authentication"- instagram_consumer_secret: "Consumer secret Instagram authentication"-enable_facebook_logins: "Enable Facebook authentication, requires facebook_app_id and facebook_app_secret. See <a href='https://meta.discourse.org/t/13394' target='_blank'>Configuring Facebook login for Discourse</a>."facebook_app_id: "App id for Facebook authentication and sharing, registered at <a href='https://developers.facebook.com/apps/' target='_blank'>https://developers.facebook.com/apps</a>"facebook_app_secret: "App secret for Facebook authentication, registered at <a href='https://developers.facebook.com/apps/' target='_blank'>https://developers.facebook.com/apps</a>"diff --git a/config/site_settings.yml b/config/site_settings.ymlindex ffe941e4734..b0ad977432d 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -386,15 +386,6 @@ login:default: ""regex: "^[\\w+-]+$"secret: true- enable_instagram_logins:- default: false- instagram_consumer_key:- default: ""- regex: "^[a-z0-9]+$"- instagram_consumer_secret:- default: ""- regex: "^[a-z0-9]+$"- secret: trueenable_facebook_logins:default: falsefacebook_app_id:diff --git a/lib/auth.rb b/lib/auth.rbindex 5febb7aedc1..f501d901574 100644--- a/lib/auth.rb+++ b/lib/auth.rb@@ -10,5 +10,4 @@ require 'auth/facebook_authenticator'require 'auth/github_authenticator'require 'auth/twitter_authenticator'require 'auth/google_oauth2_authenticator'-require 'auth/instagram_authenticator'require 'auth/discord_authenticator'diff --git a/lib/auth/instagram_authenticator.rb b/lib/auth/instagram_authenticator.rbdeleted file mode 100644index b9ba5e8940e..00000000000--- a/lib/auth/instagram_authenticator.rb+++ /dev/null@@ -1,20 +0,0 @@-# frozen_string_literal: true--class Auth::InstagramAuthenticator < Auth::ManagedAuthenticator- def name- "instagram"- end-- def enabled?- SiteSetting.enable_instagram_logins- end-- def register_middleware(omniauth)- omniauth.provider :instagram,- setup: lambda { |env|- strategy = env["omniauth.strategy"]- strategy.options[:client_id] = SiteSetting.instagram_consumer_key- strategy.options[:client_secret] = SiteSetting.instagram_consumer_secret- }- end-enddiff --git a/lib/discourse.rb b/lib/discourse.rbindex 862ed6857ff..7ac27fe8986 100644--- a/lib/discourse.rb+++ b/lib/discourse.rb@@ -326,7 +326,6 @@ module DiscourseAuth::AuthProvider.new(authenticator: Auth::GoogleOAuth2Authenticator.new, frame_width: 850, frame_height: 500), # Custom icon implemented in clientAuth::AuthProvider.new(authenticator: Auth::GithubAuthenticator.new, icon: "fab-github"),Auth::AuthProvider.new(authenticator: Auth::TwitterAuthenticator.new, icon: "fab-twitter"),- Auth::AuthProvider.new(authenticator: Auth::InstagramAuthenticator.new, icon: "fab-instagram"),Auth::AuthProvider.new(authenticator: Auth::DiscordAuthenticator.new, icon: "fab-discord")]diff --git a/spec/components/auth/instagram_authenticator_spec.rb b/spec/components/auth/instagram_authenticator_spec.rbdeleted file mode 100644index d78c632b19c..00000000000--- a/spec/components/auth/instagram_authenticator_spec.rb+++ /dev/null@@ -1,60 +0,0 @@-# frozen_string_literal: true--require 'rails_helper'--describe Auth::InstagramAuthenticator do-- it "takes over account if email is supplied" do- auth = Auth::InstagramAuthenticator.new-- user = Fabricate(:user)-- auth_token = {- info: { email: user.email },- uid: "123",- provider: "instagram"- }-- result = auth.after_authenticate(auth_token)-- expect(result.user.id).to eq(user.id)-- info = UserAssociatedAccount.find_by(provider_name: "instagram", user_id: user.id)- expect(info.info["email"]).to eq(user.email)- end-- it 'can connect to a different existing user account' do- authenticator = Auth::InstagramAuthenticator.new- user1 = Fabricate(:user)- user2 = Fabricate(:user)-- hash = {- info: { email: user1.email },- uid: "100",- provider: "instagram"- }-- result = authenticator.after_authenticate(hash, existing_account: user2)-- expect(result.user.id).to eq(user2.id)- expect(UserAssociatedAccount.exists?(provider_name: "instagram", user_id: user1.id)).to eq(false)- expect(UserAssociatedAccount.exists?(provider_name: "instagram", user_id: user2.id)).to eq(true)- end-- context 'revoke' do- fab!(:user) { Fabricate(:user) }- let(:authenticator) { Auth::InstagramAuthenticator.new }-- it 'raises exception if no entry for user' do- expect { authenticator.revoke(user) }.to raise_error(Discourse::NotFound)- end-- it 'revokes correctly' do- UserAssociatedAccount.create!(provider_name: "instagram", user_id: user.id, provider_uid: 100)- expect(authenticator.can_revoke?).to eq(true)- expect(authenticator.revoke(user)).to eq(true)- expect(authenticator.description_for_user(user)).to eq("")- end- end--enddiff --git a/spec/jobs/old_keys_reminder_spec.rb b/spec/jobs/old_keys_reminder_spec.rbindex fe68070f996..bcbb2523669 100644--- a/spec/jobs/old_keys_reminder_spec.rb+++ b/spec/jobs/old_keys_reminder_spec.rb@@ -4,7 +4,7 @@ require "rails_helper"describe Jobs::OldKeysReminder dolet!(:google_secret) { SiteSetting.create!(name: 'google_oauth2_client_secret', value: '123', data_type: 1) }- let!(:instagram_secret) { SiteSetting.create!(name: 'instagram_consumer_secret', value: '123', data_type: 1) }+ let!(:github_secret) { SiteSetting.create!(name: 'github_client_secret', value: '123', data_type: 1) }let!(:api_key) { Fabricate(:api_key, description: 'api key description') }let!(:admin) { Fabricate(:admin) }let!(:another_admin) { Fabricate(:admin) }@@ -31,7 +31,7 @@ Hello! This is a routine yearly security reminder from your Discourse instance.As a courtesy, we wanted to let you know that the following credentials used on your Discourse instance have not been updated in more than two years:google_oauth2_client_secret - #{google_secret.updated_at.to_date.to_s(:db)}-instagram_consumer_secret - #{instagram_secret.updated_at.to_date.to_s(:db)}+github_client_secret - #{github_secret.updated_at.to_date.to_s(:db)}api key description - #{api_key.created_at.to_date.to_s(:db)}No action is required at this time, however, it is considered good security practice to cycle all your important credentials every few years.@@ -48,7 +48,7 @@ Hello! This is a routine yearly security reminder from your Discourse instance.As a courtesy, we wanted to let you know that the following credentials used on your Discourse instance have not been updated in more than two years:google_oauth2_client_secret - #{google_secret.updated_at.to_date.to_s(:db)}-instagram_consumer_secret - #{instagram_secret.updated_at.to_date.to_s(:db)}+github_client_secret - #{github_secret.updated_at.to_date.to_s(:db)}twitter_consumer_secret - #{recent_twitter_secret.updated_at.to_date.to_s(:db)}api key description - #{api_key.created_at.to_date.to_s(:db)}recent api key description - #{admin.username} - #{recent_api_key.created_at.to_date.to_s(:db)}diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rbindex c530fc67ee1..7203680ac3d 100644--- a/spec/models/user_spec.rb+++ b/spec/models/user_spec.rb@@ -514,12 +514,12 @@ describe User doUserAssociatedAccount.create(user_id: user.id, provider_name: "twitter", provider_uid: "1", info: { nickname: "sam" })UserAssociatedAccount.create(user_id: user.id, provider_name: "facebook", provider_uid: "1234", info: { email: "[email protected]" })- UserAssociatedAccount.create(user_id: user.id, provider_name: "instagram", provider_uid: "examplel123123", info: { nickname: "sam" })+ UserAssociatedAccount.create(user_id: user.id, provider_name: "discord", provider_uid: "examplel123123", info: { nickname: "sam" })UserAssociatedAccount.create(user_id: user.id, provider_name: "google_oauth2", provider_uid: "1", info: { email: "[email protected]" })GithubUserInfo.create(user_id: user.id, screen_name: "sam", github_user_id: 1)user.reload- expect(user.associated_accounts.map { |a| a[:name] }).to contain_exactly('twitter', 'facebook', 'google_oauth2', 'github', 'instagram')+ expect(user.associated_accounts.map { |a| a[:name] }).to contain_exactly('twitter', 'facebook', 'google_oauth2', 'github', 'discord')endend