Add bot|user_scopes to context.authorize_result set by SingleTeamAuthorization - #1104
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1104 +/- ##
==========================================
+ Coverage 91.77% 91.79% +0.01%
==========================================
Files 186 186
Lines 6407 6408 +1
==========================================
+ Hits 5880 5882 +2
+ Misses 527 526 -1 ☔ View full report in Codecov by Sentry. |
WilliamBergamin
approved these changes
Jul 2, 2024
WilliamBergamin
left a comment
Contributor
There was a problem hiding this comment.
Neat find 💯
Changes look good to me 👍 left one comment but it isn't a blocker
| bot_token=token if _is_bot_token(token) else None, | ||
| user_id=request_user_id or (user_id if not _is_bot_token(token) else None), | ||
| user_token=token if not _is_bot_token(token) else None, | ||
| bot_scopes=auth_test_result.headers.get("x-oauth-scopes", []) if _is_bot_token(token) else None, |
Contributor
There was a problem hiding this comment.
Defining a scope = auth_test_result.headers.get("x-oauth-scopes", []) variable, similar to user_id = auth_test_result.get("user_id") may make this section clearer
Contributor
Author
There was a problem hiding this comment.
Thanks for the suggestion!
filmaj
approved these changes
Jul 2, 2024
zimeg
approved these changes
Jul 2, 2024
zimeg
left a comment
Member
There was a problem hiding this comment.
++ to a nice find! The code and tests look great to me! 🎉
Contributor
Author
|
Thanks for the reviews! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the built-in SingleTeamAuthorization middleware to attach bot|user_scopes to Request#Context#AuthorizeResult as MultiTeamsAuthorization does.
Why does this matter? This property is useful specifically when you want to know the issued OAuth token, which is associated with an incoming Slack event request, has sufficient scopes for newly added feature in a Slack app. Here is an example: https://github.com/seratch/ChatGPT-in-Slack/blob/341f50ad00f853009f3c50ff6c3133d6fd0b3dd7/app/bolt_listeners.py#L1053-L1065
Category (place an
xin each of the[ ])slack_bolt.Appand/or its core componentsslack_bolt.async_app.AsyncAppand/or its core componentsslack_bolt.adapter/docsRequirements (place an
xin each[ ])Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
./scripts/install_all_and_run_tests.shafter making the changes.