Update Slack app installation flow for GBP
What does this MR do and why?
This modifies the OAuth installation flow for the Slack app to accommodate the migration from Classic to GBP format, as described in https://api.slack.com/authentication/migration.
- Use v2 endpoints to authorize and exchange access tokens.
- Gate the behaviour behind a feature flag, and pass on a param through the flow so we know which type we're dealing with.
Related to #355997 (closed)
How to set up and validate locally
You need access to:
- Gitpod
- The Ecosystem Slack workspace: https://gitlabecosyst-nat5262.slack.com/
Setting up the Slack apps involves:
- Updating application settings in GitLab (this can be cached for up to 60s, so make sure the
Add to Slack
button uses the updated value before continuing). - Updating URLs in Slack app settings (OAuth redirect URL and slash command target URL).
- See the linked docs for details.
Reinstalling the app involves:
- Go to the GitLab integration form.
- Remove the project if the app was already installed.
- Also remove the chat name from
/-/profile/chat_names
if it exists.
- Click
Add to Slack
. - Click
Allow
on Slack's authorization screen. - Get redirected back to the integration form with a success message and the connected project.
Testing the slash command involves:
- Run the slash command from Slack with the configured command and project path, e.g.
/dev-markus gitlab-org/gitlab-test issue show 1
. - When using the v1 flow:
- The user was already connected during installation, so you should get the issue response immediately.
- When using the v2 flow:
- Get a response with a link to connect the user.
- Follow the link and click
Authorize
to connect the user. - Run the slash command again, and get the issue response this time.
Testing scenarios:
- Boot up a Gitpod instance on this branch.
-
Set up the
GitLab (dev)
Slack app (updated to GBP) on the Gitpod instance: https://gitlab.com/gitlab-org/ecosystem-stage/integrations/team/-/blob/main/integrations/slack.md#set-up-a-development-environment-for-the-gitlab-dev-slack-application- Reinstall the app, this should still work with the v1 flow.
- Test the slash command.
- Enable the FF:
Feature.enable(:slack_app_use_v2_flow)
- Reinstall the app, this should also work with the v2 flow.
- Test the slash command.
-
Set up the
GitLab (snapshot)
Slack app (Classic, not updated) on the Gitpod instance: https://gitlab.com/gitlab-org/ecosystem-stage/integrations/team/-/blob/main/integrations/slack.md#test-against-the-gitlab-snapshot-slack-application-
Reinstall the app, this should fail with an error
GitLab (snapshot) doesn’t have a bot user to install
because Classic apps only work with the v1 flow. - Disable the FF:
Feature.disable(:slack_app_use_v2_flow)
- Reinstall the app, this should now work with the v1 flow.
- Test the slash command.
-
Reinstall the app, this should fail with an error
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Markus Koller