-
Notifications
You must be signed in to change notification settings - Fork 399
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, fix redirect uri bug #1116
Add option to disable state verification, fix redirect uri bug #1116
Conversation
f5e4c69
to
beb3d57
Compare
beb3d57
to
79a77cd
Compare
Codecov Report
@@ Coverage Diff @@
## main #1116 +/- ##
==========================================
+ Coverage 70.92% 71.71% +0.79%
==========================================
Files 14 15 +1
Lines 1324 1354 +30
Branches 392 402 +10
==========================================
+ Hits 939 971 +32
- Misses 311 312 +1
+ Partials 74 71 -3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated changes include:
- Moved docs changes to separate PR.
- Utility verification function that throws an error when custom redirect options are incomplete or invalid + tests for those scenarios at App and Receiver levels
- Tests to check that install options are being directly handed over to handleCallback when stateVerification is disabled.
- Did some reorganization of SocketModeReceiver and HTTPReceiver tests sections for readability.
Thanks in advance for your 👀 - I will squash and merge when the PR is ready!
@@ -117,217 +117,344 @@ describe('HTTPReceiver', function () { | |||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added additional describe
sections and reorganized some of the tests here and also in SocketModeReceiver.spec.ts to make the test files more consistent with one another and to make navigating test files / reading test output a little more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I attempted to incorporate state validation related tests for this, but ran into an issue with the requestHandler
being a private function - wasn't sure how to really set up a fake request. I see that we don't really have the same test coverage for ExpressReceiver
that we do for the other receivers and I'm wondering if that's a known limitation.
cf22ddc
to
283f6b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one comment. As long as your Slack app has only one Redirect URI in its settings, skipping to have redirect_uri
parameter should be allowed. Also, if we add the validation about the existence of redirectUri
as a requirement, it'll be a breaking change to many of the existing OAuth ebaled apps. They will need updates when upgrading bolt-js version.
scopes, | ||
redirectUri, | ||
}), AppInitializationError); | ||
// missing redirectUri |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not setting redirectUri
should be allowed. You can initiate the OAuth flow without redirect_uri parameter when your Slack app has only one redirect_uri setting.
I won't repeat the same comment for HTTPReceiver and SocketModeReceiver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I have modified the check so now it makes sure that if redirectUri
is supplied, redirectUriPath
is required only.
redirectUriPath?: HTTPReceiverInstallerOptions['redirectUriPath'], | ||
} | ||
|
||
export function verifyRedirectOpts({ redirectUri, redirectUriPath }: RedirectOptions): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment on the corresponding test code side but missing only redirectUri should be okay.
08b9f87
to
efc5e17
Compare
efc5e17
to
f053a34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Hey, other reviewers! This one is the last pull request waiting for merging in the v3.7.0 release milestone: https://github.com/slackapi/bolt-js/milestone/11 If you have any comments on this PR, submit your reviews by next @srajiang Can I ask you to work on the release early next week? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Left a couple minor comments.
Co-authored-by: Fil Maj <maj.fil@gmail.com>
Co-authored-by: Fil Maj <maj.fil@gmail.com>
Summary
Fixes #1101
Fixes #1115
See both for more context.
It adds the option to disable state verification during OAuth flow via a
stateVerification
flag. By default this will be true. When state verification is disabled,stateSecret
is no longer required, so this updates error messages associated with that previous hard requirement.This PR also fixes an issue where the user supplied redirect_uri is not properly being passed as part of oauth/v2/authorize request params. It adds a separate top-level
redirectUri
parameter that contains the full url and includes some input validation.Todo
Requirements (place an
x
in each[ ]
)