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

Add more callbacks (beforeRedirection, before/afterInstallation, async success/failure) in InstallProvider #1438

Closed
1 of 6 tasks
seratch opened this issue Feb 27, 2022 · 0 comments · Fixed by #1442
Closed
1 of 6 tasks
Assignees
Labels
enhancement M-T: A feature request for new functionality pkg:oauth applies to `@slack/oauth-helper`
Milestone

Comments

@seratch
Copy link
Member

seratch commented Feb 27, 2022

As discussed at slackapi/bolt-js#1211, @slack/oauth (and @slack/bolt that relies on it) needs more flexibility to cover real-world use cases such as service account mapping (Slack + other services) and user activity tracking.

My recent pull request #1436 introduces handleInstallPath() as a new easier way to securely handling /slack/install URL requests. With that, now we have the following handlers:

async method args returned value description
async handleInstallPath request, response, InstallURLOptions void Build Slack authorize URL, set state to the brwoser, and redirect the installing user to slack.com. This method will be added in v2.5. (by #1436)
async handleCallback request, response, CallbackOptions, InstallURLOptions void
CallbackOptions.success Installation, InstallURLOptions, IncomingMessage, ServerResponse void
CallbackOptions.failure CodedError, InstallURLOptions, IncomingMessage, ServerResponse void

To resolve the issues mentioned at slackapi/bolt-js#1211, we can add more callbacks:

async method args returned value description
async handleInstallPath request, response, InstallURLOptions void Build Slack authorize URL, set state to the brwoser, and redirect the installing user to slack.com. This method will be added in v2.5. (by #1436)
async InstallPathOptions.beforeRedirection request, response, InstallURLOptions boolean (won't proceed when false) Enable developers to customize the response headers etc. before redireting installing users. This will be added in v2.5.
async handleCallback request, response, CallbackOptions, InstallURLOptions void
async CallbackOptions.beforeInstallation InstallURLOptions, request, response boolean (won't proceed when false) Enable developers to have custom logic right after state parameter validation. Before performing oauth.v2.access API call (=installing the app into a workspace), you can do anything here. This will be added in v2.5.
async CallbackOptions.afterInstallation Installation, InstallURLOptions, request, response boolean (won't proceed when false) Enable developers to have custom logic right after performing oauth.v2.access API call (=installing the app into a workspace). Before storing the installation result, you can do anything here. This will be added in v2.5.
CallbackOptions.success Installation, InstallURLOptions, IncomingMessage, ServerResponse void
async CallbackOptions.successAsync Installation, InstallURLOptions, IncomingMessage, ServerResponse void CallbackOptions.success is not an async function. This can be problematic for many use cases. This method be added in v2.5.
CallbackOptions.failure CodedError, InstallURLOptions, IncomingMessage, ServerResponse void
async CallbackOptions.failureAsync CodedError, InstallURLOptions, IncomingMessage, ServerResponse void CallbackOptions.failure is not an async function. This can be problematic for many use cases. This method be added in v2.5.

Packages:

Select all that apply:

  • @slack/web-api
  • @slack/rtm-api
  • @slack/webhooks
  • @slack/oauth
  • @slack/socket-mode
  • I don't know

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

@seratch seratch added enhancement M-T: A feature request for new functionality pkg:oauth applies to `@slack/oauth-helper` labels Feb 27, 2022
@seratch seratch added this to the oauth@2.5.0 milestone Feb 27, 2022
@seratch seratch self-assigned this Feb 27, 2022
seratch added a commit to seratch/node-slack-sdk that referenced this issue Mar 1, 2022
…Installation, async success/failure) in InstallProvider
seratch added a commit to seratch/node-slack-sdk that referenced this issue Mar 2, 2022
…Installation, async success/failure) in InstallProvider
seratch added a commit to seratch/node-slack-sdk that referenced this issue Mar 2, 2022
…Installation, async success/failure) in InstallProvider
seratch added a commit that referenced this issue Mar 2, 2022
…tion, async success/failure) in InstallProvider (#1442)

Co-authored-by: Fil Maj <maj.fil@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement M-T: A feature request for new functionality pkg:oauth applies to `@slack/oauth-helper`
Projects
None yet
1 participant