Skip to content

Commit 15e6403

Browse files
authored
CV2-6689: Deprecate Slack authentication (#2416)
* CV2-6689: Remove slack auth * CV2-6689: fix tests 1/2 * CV2-6689: fix tests 2/2 * CV2-6689: Apply PR comments * CV2-6689: apply PR comments
1 parent 711671d commit 15e6403

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1279
-3094
lines changed

Gemfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ gem 'devise', '~> 4.8'
4949
gem 'devise-i18n', '~> 1.10.0'
5050
gem 'devise-two-factor', '~> 4.0.2'
5151
gem 'devise_invitable', '~> 2.0'
52-
gem 'omniauth-twitter'
5352
gem 'omniauth-facebook'
54-
gem 'omniauth-slack'
5553
gem 'elasticsearch', '7.10.1'
5654
gem 'elasticsearch-api', '7.10.1'
5755
gem 'elasticsearch-transport', '7.10.1'

Gemfile.lock

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ GEM
457457
mini_portile2 (~> 2.8.2)
458458
racc (~> 1.4)
459459
numerizer (0.1.1)
460-
oauth (0.5.8)
461460
oauth2 (1.4.9)
462461
faraday (>= 0.17.3, < 3.0)
463462
jwt (>= 1.0, < 3.0)
@@ -469,17 +468,9 @@ GEM
469468
rack (>= 1.6.2, < 3)
470469
omniauth-facebook (9.0.0)
471470
omniauth-oauth2 (~> 1.2)
472-
omniauth-oauth (1.2.0)
473-
oauth
474-
omniauth (>= 1.0, < 3)
475471
omniauth-oauth2 (1.3.1)
476472
oauth2 (~> 1.0)
477473
omniauth (~> 1.2)
478-
omniauth-slack (2.3.0)
479-
omniauth-oauth2 (~> 1.3.1)
480-
omniauth-twitter (1.4.0)
481-
omniauth-oauth (~> 1.1)
482-
rack
483474
open_uri_redirections (0.2.1)
484475
opentelemetry-api (1.1.0)
485476
opentelemetry-common (0.19.6)
@@ -947,8 +938,6 @@ DEPENDENCIES
947938
nokogiri (= 1.16.5)
948939
omniauth-facebook
949940
omniauth-google-oauth2!
950-
omniauth-slack
951-
omniauth-twitter
952941
open_uri_redirections
953942
opentelemetry-exporter-otlp
954943
opentelemetry-instrumentation-action_pack

app/controllers/api/v1/admin_controller.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
class Api::V1::AdminController < Api::V1::BaseApiController
22
before_action :authenticate_from_token!, except: [:save_messenger_credentials_for_smooch_bot, :save_instagram_credentials_for_smooch_bot]
33

4-
# GET /api/admin/user/slack?uid=:uid
5-
def slack_user
6-
user = User.find_with_omniauth(params[:uid].to_s, 'slack')
7-
slack_account = user.accounts.where(provider: 'slack').first unless user.nil?
8-
user = { token: slack_account.token } unless slack_account.nil?
9-
render_user user, 'slack_uid'
10-
end
11-
124
# GET /api/admin/smooch_bot/:bot-installation-id/authorize/messenger?token=:bot-installation-token
135
def save_messenger_credentials_for_smooch_bot
146
self.save_facebook_credentials_for_smooch_bot('messenger')

app/controllers/api/v1/omniauth_callbacks_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module Api
22
module V1
33
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
44
include FacebookAuthentication
5-
include SlackAuthentication
65
include GoogleAuthentication
76

87
before_action :store_request

app/controllers/concerns/slack_authentication.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/mailers/assignment_mailer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def notify(event, author, recipient, assigned, message = nil)
5151
updated_at: updated_at,
5252
total_tasks: total_tasks,
5353
completed_tasks: completed_tasks,
54-
button: I18n.t("slack.fields.view_button", **{
54+
button: I18n.t("mails_notifications.assignment.view_button", **{
5555
type: I18n.t("activerecord.models.#{model}"), app: CheckConfig.get('app_name')
5656
}),
5757
description: description,

app/models/annotations/dynamic.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,6 @@ def create_fields
180180
end
181181
end
182182

183-
def create_fields_bg(set_fields)
184-
data = JSON.parse(set_fields)
185-
data.each do |field_name, value|
186-
next unless DynamicAnnotation::FieldInstance.where(name: field_name).exists?
187-
value ||= ""
188-
f = create_field(field_name, value)
189-
f.save!
190-
end
191-
end
192-
193183
def update_fields
194184
if !self.set_fields.blank? && self.json_schema.blank?
195185
fields = self.fields

app/models/concerns/user_multi_auth_login.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module UserMultiAuthLogin
44
extend ActiveSupport::Concern
55

66
included do
7-
LOGINPROVIDERS = %w[slack google_oauth2]
7+
LOGINPROVIDERS = %w[google_oauth2]
88

99
def self.from_omniauth(auth, current_user=nil)
1010
self.update_facebook_uuid(auth)
@@ -144,11 +144,7 @@ def providers
144144
values = []
145145
provider_accounts.each do |a|
146146
info = a.omniauth_info.dig('info')
147-
if a.provider == 'slack'
148-
name = "#{info['nickname']} at #{info['team']}"
149-
else
150-
name = info['name']
151-
end
147+
name = info['name']
152148
values << { connected: true, uid: "#{a.uid}", allow_disconnect: allow_disconnect, info: "#{provider_label}: #{name}" }
153149
end
154150
providers << { key: p, add_another: true, values: values }

app/models/team_user.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class TeamUser < ApplicationRecord
77

88
validates :status, presence: true
99
validates :user_id, uniqueness: { scope: :team_id, message: 'already joined this team' }
10-
validate :user_is_member_in_slack_team
1110

1211
check_settings
1312

@@ -112,28 +111,6 @@ def set_role_default_value
112111
self.role = 'collaborator' if self.role.nil?
113112
end
114113

115-
# Validate that a Slack user is part of the team's `slack_teams` setting.
116-
# The `slack_teams` should be a hash of the form:
117-
# { 'Slack team 1 id' => 'Slack team 1 name', 'Slack team 2 id' => 'Slack team 2 name', ... }
118-
def user_is_member_in_slack_team
119-
return if self.user.nil?
120-
accounts = self.user.get_social_accounts_for_login({provider: 'slack'})
121-
if !self.user.nil? && !accounts.blank? && self.team.setting(:slack_teams)&.is_a?(Hash)
122-
accounts_team = accounts.collect{|a| a.omniauth_info&.dig('info', 'team_id')}
123-
unless (self.team.setting(:slack_teams)&.keys & accounts_team).empty?
124-
# Auto-approve slack user
125-
self.status = 'member'
126-
else
127-
params = {
128-
default: "Sorry, you cannot join %{team_name} because it is restricted to members of the Slack team(s) %{teams}.",
129-
team_name: self.team.name,
130-
teams: self.team.setting(:slack_teams).values.join(', ')
131-
}
132-
errors.add(:base, I18n.t(:slack_restricted_join_to_members, **params))
133-
end
134-
end
135-
end
136-
137114
def update_user_cached_teams_after_save
138115
if self.status == 'member'
139116
self.update_user_cached_teams(:add)

app/models/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ToSOrPrivacyPolicyReadError < StandardError; end
3131
has_many :explainers
3232

3333
devise :recoverable, :rememberable, :trackable, :validatable, :confirmable,
34-
:omniauthable, omniauth_providers: [:twitter, :facebook, :slack, :google_oauth2]
34+
:omniauthable, omniauth_providers: [:facebook, :google_oauth2]
3535

3636
before_create :skip_confirmation_for_non_email_provider, :set_last_received_terms_email_at
3737
after_create :create_source_and_account, :set_source_image

0 commit comments

Comments
 (0)