DEV: remove instagram login site settings and auth classes. (#11073)

DEV: remove instagram login site settings and auth classes. (#11073)

Instagram removed the support for login and should use Facebook login instead.

diff --git a/Gemfile b/Gemfile
index 68bb1a5..cb86d7e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -101,7 +101,6 @@ gem 'css_parser', require: false
 gem 'omniauth'
 gem 'omniauth-facebook'
 gem 'omniauth-twitter'
-gem 'omniauth-instagram'
 gem 'omniauth-github'
 
 gem 'omniauth-oauth2', require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index 4a5a6c3..1e557f2 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -226,9 +226,6 @@ GEM
       jwt (>= 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)
       oauth
       omniauth (~> 1.0)
@@ -504,7 +501,6 @@ DEPENDENCIES
   omniauth-facebook
   omniauth-github
   omniauth-google-oauth2
-  omniauth-instagram
   omniauth-oauth2
   omniauth-twitter
   onebox
diff --git a/app/assets/stylesheets/common/components/buttons.scss b/app/assets/stylesheets/common/components/buttons.scss
index 1355589..e00d5c2 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.yml
index 41b388b..608a288 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.yml
index ffe941e..b0ad977 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: true
   enable_facebook_logins:
     default: false
   facebook_app_id:
diff --git a/lib/auth.rb b/lib/auth.rb
index 5febb7a..f501d90 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.rb
deleted file mode 100644
index b9ba5e8..0000000
--- 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
-end
diff --git a/lib/discourse.rb b/lib/discourse.rb
index 862ed68..7ac27fe 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -326,7 +326,6 @@ module Discourse
     Auth::AuthProvider.new(authenticator: Auth::GoogleOAuth2Authenticator.new, frame_width: 850, frame_height: 500), # Custom icon implemented in client
     Auth::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.rb
deleted file mode 100644
index d78c632..0000000
--- 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
-
-end
diff --git a/spec/jobs/old_keys_reminder_spec.rb b/spec/jobs/old_keys_reminder_spec.rb
index fe68070..bcbb252 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 do
   let!(: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) }

[... diff too long, it was truncated ...]

GitHub sha: 34742300

This commit appears in #11073 which was approved by SamSaffron. It was merged by vinothkannans.