Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support workspace apps #65

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/omniauth/strategies/slack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Slack < OmniAuth::Strategies::OAuth2
# User ID is not guaranteed to be globally unique across all Slack users.
# The combination of user ID and team ID, on the other hand, is guaranteed
# to be globally unique.
uid { "#{user_identity['id']}-#{team_identity['id']}" }
uid { "#{user_id}-#{team_id}" }

info do
hash = {
Expand All @@ -49,7 +49,8 @@ class Slack < OmniAuth::Strategies::OAuth2
user_info: user_info, # Requires the users:read scope
team_info: team_info, # Requires the team:read scope
web_hook_info: web_hook_info,
bot_info: bot_info
bot_info: bot_info,
workspace_info: workspace_info
}
}
end
Expand Down Expand Up @@ -98,7 +99,20 @@ def bot_info
access_token.params['bot']
end

def workspace_info
return {} unless access_token.params.key? 'team_id'
access_token.params.except(['ok', 'access_token', 'token_type'])
end

private

def user_id
user_identity['id'].presence || workspace_info.dig('authorizing_user', 'user_id').presence
end

def team_id
team_identity['id'].presence || workspace_info['team_id'].presence
end

def callback_url
full_host + script_name + callback_path
Expand Down