Slack Integration with OAuth 2.0
Review Request #11289 — Created Nov. 19, 2020 and updated
Slack Integration workflow now uses OAuth 2.0.
Users fill out the form with the credentials provided
by Slack App and clicks on a button Authorize to bring
up the OAuth 2.0 popup workflow.
- Manually tested adding Slack integration using OAuth 2.0 workflow
- Access token is successfully saved into config
- Slack integration successfully sends notifications to
linked channel
with a test Slack App set up
- Ran unit tests, all works except 2 needing image attachments:
- test_notify_new_review_request_with_image_file_attachment
- test_notify_updated_review_request_with_new_image_attachments
Summary | ID | Author |
---|---|---|
be4410291030ca993102567f6ed4a92bd00629e8 | ruonan | |
b3b36fdcd6858fee5d70fe86dd13ff2f8d089f26 | ruonan |
Description | From | Last Updated |
---|---|---|
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
E303 too many blank lines (2) |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
E305 expected 2 blank lines after class or function definition, found 1 |
reviewbot | |
W292 no newline at end of file |
reviewbot | |
Col: 10 'authorize' is defined but never used. |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
E305 expected 2 blank lines after class or function definition, found 1 |
reviewbot | |
W292 no newline at end of file |
reviewbot | |
Col: 10 'authorize' is defined but never used. |
reviewbot | |
Col: 10 'authorize' is defined but never used. |
reviewbot | |
I believe that python files, do not follow the camelCase naming scheme. |
jblazusi | |
Include a line between lines 2 and 3. |
jblazusi | |
Needs an empty line between line 7 and 8 to separate 3rd party modules and current project codebase |
hailan | |
Lines 10 and 11 should be swapped to maintain alphabetical order. |
jblazusi | |
Delete 'webhook URL' |
hailan | |
I could be totally wrong, but was it not already in utf-8? |
hailan | |
Remove print statement |
hailan | |
Update Trello to Slack |
hailan | |
Maybe use from django.utils.six.moves.urllib.request |
hailan | |
Include another empty line below line 10. |
jblazusi | |
Col: 10 'authorize' is defined but never used. |
reviewbot | |
I noticed that you are using var here, but are not redeclaring the variable, perhaps this should be const. |
jblazusi | |
I noticed you are experiencing some extra whitespace errors. I find that these can be hard to find unless you … |
jblazusi | |
I could be wrong, but this function does not seem to follow camelCase styling. |
jblazusi | |
I think we should be using let here. |
jblazusi | |
Instead of making another variable param, I think that we can just return urlObj.searchParams.get(name); |
jblazusi | |
I could be wrong about this as well, but I think we could use let here instead of var |
jblazusi | |
This variable does not seem to be redeclared, so therefore I think it should be const. |
jblazusi | |
Perhaps it would be useful to console.log or log the error somehow to make the error easier to determine when … |
jblazusi | |
Col: 10 'authorize' is defined but never used. |
reviewbot | |
Col: 27 Missing semicolon. |
reviewbot | |
Please add a module docstring at the top of this file. |
david | |
Let's use django.util.html.format_html here: return format_html('<button onclick="authorize(\'{0}\')">{1}</button>', server, _('Authorize')) |
david | |
We should wrap "Authorize" in a gettext call and format it into the HTML. |
david | |
Add a blank line between these two. |
david | |
Add a blank line between these two. |
david | |
Please use single quotes here. |
david | |
Instead of +, can you use a format operation? |
david | |
These two lines will need to be swapped. |
david | |
Can we add some blank lines in here to space things out a bit? |
david | |
Why are these commented out? |
david | |
This doesn't appear to be used. |
david | |
Add another blank line here. |
david | |
Please add a period in this docstring. |
david | |
This needs a better docstring. |
david | |
There's an extra blank line here that can go away. |
david | |
For this, please use (at the top), from django.utils.six.moves.urllib.parse import parse_qs and then just call parse_qs. |
david | |
Col: 10 'authorize' is defined but never used. |
reviewbot | |
This file should be named .es6.js, since you're using ES6 features. |
david | |
This can use an ES6 template string: const redirect = `${redirectServer}rbintegrations/slack/oauth/`; |
david | |
Please use single quotes throughout. |
david | |
This can also be a template string. |
david | |
You've got some trailing whitespace throughout this file. |
david | |
This can be const. |
david | |
Instead of the magic number 4, can we compare against XMLHttpRequest.DONE? |
david | |
Col: 10 'authorize' is defined but never used. |
reviewbot | |
We can get rid of the warning here, and make things more correct and reliable wrt. babel-compilation by assigning this … |
david | |
There's still some trailing whitespace within this file. Please look at the diff here on Review board and get rid … |
david | |
console.error is probably more approriate than console.log here. |
david | |
E501 line too long (84 > 79 characters) |
reviewbot | |
Col: 2 Missing semicolon. |
reviewbot |
- Commits:
-
Summary ID Author 0acc9d0a86aa177e34b9f2d7a6afb854291f3a78 ruonan 383a156e8fae540c36d8141839d32339440e988d ruonan a1d2c37223634394941b0313e47d5cbe1a1a031f ruonan - Diff:
-
Revision 2 (+914 -312)
Checks run (2 failed)
flake8
JSHint
- Commits:
-
Summary ID Author 383a156e8fae540c36d8141839d32339440e988d ruonan a1d2c37223634394941b0313e47d5cbe1a1a031f ruonan 383a156e8fae540c36d8141839d32339440e988d ruonan 0d704d4b1b8995621146080e90e4f491c8f082b4 ruonan - Diff:
-
Revision 3 (+917 -317)
- Commits:
-
Summary ID Author 383a156e8fae540c36d8141839d32339440e988d ruonan 0d704d4b1b8995621146080e90e4f491c8f082b4 ruonan fd1b5c6e9b1520ed1e0ad4d95c4d94ddb38db446 ruonan - Diff:
-
Revision 4 (+904 -304)
- Groups:
-
Awesome job, Ruonan! Looking great!
I'm also learning about OAuth right now, so I'll definitely check this out
locally at a later time. -
-
-
-
-
-
-
Awesome Work!
Unfortunately, I experienced 28 test failures, although it is possible that I may have done something wrong when applying the patch.
Due to these test failures, I refrained from doing any manual testing.
I imported all the files, ran./setup develop
thenrbtext test -m rbintegrations.slack
(For the record I am also using RB4).
Please let me know if I did something incorrectly on my end. -
-
-
-
-
I noticed that you are using
var
here, but are not redeclaring the variable, perhaps this should beconst
. -
I noticed you are experiencing some extra whitespace errors. I find that these can be hard to find unless you enable whitespaces in your text editor. Then they are easier to find and remove.
Similar, it does not seem like we are redeclaring win here so perhaps we should use
const
. -
-
-
Instead of making another variable param, I think that we can just
return urlObj.searchParams.get(name);
-
-
-
Perhaps it would be useful to
console.log
or log the error somehow to make the error easier to determine when debugging in the future?
- Commits:
-
Summary ID Author fd1b5c6e9b1520ed1e0ad4d95c4d94ddb38db446 ruonan 8f46c0b5c1bd05adbbb76050bb62ce26030cc2be ruonan 8552d8c96243566bb93e7ac72e3b12130e2f5420 ruonan - Diff:
-
Revision 5 (+906 -308)
- Commits:
-
Summary ID Author 8f46c0b5c1bd05adbbb76050bb62ce26030cc2be ruonan 8552d8c96243566bb93e7ac72e3b12130e2f5420 ruonan 778441228f7713bc2254d8d22cecf8c19ed39484 ruonan - Diff:
-
Revision 6 (+904 -306)
-
-
-
Let's use
django.util.html.format_html
here:return format_html('<button onclick="authorize(\'{0}\')">{1}</button>', server, _('Authorize'))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
For this, please use (at the top),
from django.utils.six.moves.urllib.parse import parse_qs
and then just callparse_qs
. -
-
This can use an ES6 template string:
const redirect = `${redirectServer}rbintegrations/slack/oauth/`;
-
-
-
-
-
- Commits:
-
Summary ID Author 778441228f7713bc2254d8d22cecf8c19ed39484 ruonan 778441228f7713bc2254d8d22cecf8c19ed39484 ruonan 9d1ad47414ba01c7baa61230e434cad0ccc41feb ruonan - Diff:
-
Revision 7 (+948 -332)
-
-
We can get rid of the warning here, and make things more correct and reliable wrt. babel-compilation by assigning this to the
window
object. Let's also make the name more specific:window.authorizeSlack = function(redirectServer) { ... }
-
There's still some trailing whitespace within this file. Please look at the diff here on Review board and get rid of them.
-
- Commits:
-
Summary ID Author 778441228f7713bc2254d8d22cecf8c19ed39484 ruonan 9d1ad47414ba01c7baa61230e434cad0ccc41feb ruonan bd22e0e1807609515308fc40723a5d6a11874e61 ruonan - Diff:
-
Revision 8 (+918 -304)
- Commits:
-
Summary ID Author bd22e0e1807609515308fc40723a5d6a11874e61 ruonan be4410291030ca993102567f6ed4a92bd00629e8 ruonan - Diff:
-
Revision 9 (+920 -304)
Checks run (2 succeeded)
- Commits:
-
Summary ID Author be4410291030ca993102567f6ed4a92bd00629e8 ruonan be4410291030ca993102567f6ed4a92bd00629e8 ruonan b3b36fdcd6858fee5d70fe86dd13ff2f8d089f26 ruonan - Diff:
-
Revision 10 (+922 -310)