Skip to content

Update Slack app installation flow for GBP

Markus Koller requested to merge 355997-update-slack-app-installation-flow into master

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:

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:

  1. Boot up a Gitpod instance on this branch.
  2. 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
    1. Reinstall the app, this should still work with the v1 flow.
    2. Test the slash command.
    3. Enable the FF: Feature.enable(:slack_app_use_v2_flow)
    4. Reinstall the app, this should also work with the v2 flow.
    5. Test the slash command.
  3. 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
    1. 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.
    2. Disable the FF: Feature.disable(:slack_app_use_v2_flow)
    3. Reinstall the app, this should now work with the v1 flow.
    4. Test the slash command.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Markus Koller

Merge request reports