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

Instagram removed the support for login and should use Facebook login instead.
This commit is contained in:
Vinoth Kannan 2020-10-30 09:09:56 +05:30 committed by GitHub
parent 8f7f5204db
commit 347423007a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 5 additions and 111 deletions

View File

@ -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

View File

@ -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

View File

@ -183,12 +183,6 @@
background: var(--google-hover);
}
}
&.instagram {
background: var(--instagram);
&:hover {
background: var(--instagram-hover);
}
}
&.facebook {
background: $facebook;
&:hover {

View File

@ -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>"

View File

@ -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:

View File

@ -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'

View File

@ -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

View File

@ -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")
]

View File

@ -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

View File

@ -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) }
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)}

View File

@ -514,12 +514,12 @@ describe User do
UserAssociatedAccount.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: "test@example.com" })
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: "sam@sam.com" })
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')
end
end