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 option to disable state verification #1339

Merged
merged 29 commits into from
Sep 20, 2021

Conversation

srajiang
Copy link
Member

@srajiang srajiang commented Sep 20, 2021

Summary

This PR partially fixes bolt-js/#1101 by adding the option to disable state verification during OAuth flow via a stateVerification flag. By default stateVerification = true. Users can pass stateVerification: false as an OAuth option via App installerOptions object.

Previous (reverted) changes allowed option to disable state verification but continued usage of default state store for state generation. This current set of changes disables the default state store when stateVerification = false.

Requirements (place an x in each [ ])

Copy link
Member Author

@srajiang srajiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please give feedback and thoughts, thank you!

* @param installationStore - Interface to store and retrieve installation data from the database
* @param authVersion - Can be either `v1` or `v2`. Determines which slack Oauth URL and method to use
* @param logger - Pass in your own Logger if you don't want to use the built-in one
* @param logLevel - Pass in the log level you want (ERROR, WARN, INFO, DEBUG). Default is INFO
*/
export class InstallProvider {
public stateStore: StateStore;
public stateStore?: StateStore;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When stateVerification = false a stateStore is not necessary anymore.

@srajiang srajiang marked this pull request as ready for review September 20, 2021 20:47
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment on A TODO. Looks great to me. Squash commits when merging this 👋

@@ -546,6 +579,7 @@ export interface CallbackOptions {
export interface StateStore {
// Returned Promise resolves for a string which can be used as an
// OAuth state param.
// TODO: Revisit design. Does installOptions need to be encoded in state if metadata is static?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I were you, I would add something like this:

TODO: With bolt-js built-in receivers, InstallURLOptions is always static. This means that metadata value is not so useful for customizing OAuth flows per user. If we enhance both this SDK and bolt-js to have a function that accepts request information (e.g., path, headers, query string) plus dynamically generate InstallURLOptions per request, developers can easily switch not only medatada but also redirect_uri, scopes, and user_scopes to support multiple installation patterns.

@srajiang srajiang merged commit 14ffa2b into slackapi:main Sep 20, 2021
srajiang added a commit that referenced this pull request Dec 10, 2021
* Add option to disable state verification
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add installer_options.state_verification to customize OAuth flow for admin's app installations
2 participants