-
-
-
reviewboard/settings.py (Diff revision 1) 'from settings_local import *' used; unable to detect undefined names
-
reviewboard/settings.py (Diff revision 1) Col: 18 E126 continuation line over-indented for hanging indent
-
-
-
-
-
[WIP]Add OAuth2 provider support
Review Request #7285 — Created May 2, 2015 and discarded
Information | |
---|---|
Chenxi | |
Review Board | |
master | |
Reviewers | |
reviewboard | |
This is about making Review Board work as an OAuth2 provider, so that other services can link up with Review Board and request permissions to perform operations.
About the code
- the
add_valid_policy_ids
inreviewboard/settings.py
is a recursive function to walking the WebAPIResource tree for adding scopes to OAUTH2_PROVIDER.SCOPES which will be used for validation inAccessToken.allow_scopes
(inoauth2_provider/models.py
)
- modify
WebAPIResource.call_method_view
(inreviewboard/webapi/base.py
) to not just check the policies around API Tokens, but also any OAuth2 tokens.
How to use
- Firstly install the toolkit:
pip install django-oauth-toolkit
- Now we can use following shell to get the access token.
curl -X POST -d "grant_type=password&username=<user_name>&password=<password>&scope=read" -u"<client_id>:<client_secret>" http://localhost:8000/o/token/
- We can use following code to access
UserResource
[We useWebAPIResource.policy_id
for the scope name of that resource]. Thus we succuessfully apply the verify mechanism to our code.
curl -H "Authorization: Bearer <your_access_token_with_user_scope>" http://localhost:8000/api/users/<username>/
Description | From | Last Updated |
---|---|---|
'django_reset' imported but unused |
![]() |
|
'from settings_local import *' used; unable to detect undefined names |
![]() |
|
Col: 18 E126 continuation line over-indented for hanging indent |
![]() |
|
Col: 80 E501 line too long (95 > 79 characters) |
![]() |
|
'PIPELINE_JS' imported but unused |
![]() |
|
'PIPELINE_CSS' imported but unused |
![]() |
|
Col: 80 E501 line too long (84 > 79 characters) |
![]() |
|
Col: 2 W292 no newline at end of file |
![]() |
|
'django_reset' imported but unused |
![]() |
|
'from settings_local import *' used; unable to detect undefined names |
![]() |
|
Col: 18 E126 continuation line over-indented for hanging indent |
![]() |
|
'PIPELINE_JS' imported but unused |
![]() |
|
'PIPELINE_CSS' imported but unused |
![]() |
|
Col: 80 E501 line too long (84 > 79 characters) |
![]() |
|
Col: 20 E225 missing whitespace around operator |
![]() |
|
Col: 25 E231 missing whitespace after ',' |
![]() |
|
Col: 9 E265 block comment should start with '# ' |
![]() |
|
'django_reset' imported but unused |
![]() |
|
'from settings_local import *' used; unable to detect undefined names |
![]() |
|
Col: 18 E126 continuation line over-indented for hanging indent |
![]() |
|
'PIPELINE_JS' imported but unused |
![]() |
|
'PIPELINE_CSS' imported but unused |
![]() |
|
Col: 1 E302 expected 2 blank lines, found 1 |
![]() |
|
Col: 8 E111 indentation is not a multiple of four |
![]() |
|
Col: 1 E402 module level import not at top of file |
![]() |
|
Col: 37 W292 no newline at end of file |
![]() |
|
Col: 5 E265 block comment should start with '# ' |
![]() |
|
Col: 20 E225 missing whitespace around operator |
![]() |
|
Col: 25 E231 missing whitespace after ',' |
![]() |
|
Col: 9 E265 block comment should start with '# ' |
![]() |
|
'django_reset' imported but unused |
![]() |
|
'from settings_local import *' used; unable to detect undefined names |
![]() |
|
'PIPELINE_CSS' imported but unused |
![]() |
|
'PIPELINE_JS' imported but unused |
![]() |
|
Col: 1 E402 module level import not at top of file |
![]() |
|
'django_reset' imported but unused |
![]() |
|
'from settings_local import *' used; unable to detect undefined names |
![]() |
|
'PIPELINE_JS' imported but unused |
![]() |
|
'PIPELINE_CSS' imported but unused |
![]() |
|
Needs a docstring. |
|
|
No blank line here. |
|
|
You can use %-formatting to build this string more efficiently. |
|
|
These should go with the django/djblets imports. |
|
|
This doesn't need a leading underscore. |
|
|
Needs a docstring. |
|
|
You can use .split(' ', 1)[0] to get only the first element out. |
|
|
Needs a docstring. |
|
|
'django_reset' imported but unused |
![]() |
|
'from settings_local import *' used; unable to detect undefined names |
![]() |
|
'PIPELINE_JS' imported but unused |
![]() |
|
'PIPELINE_CSS' imported but unused |
![]() |
|
Col: 1 E402 module level import not at top of file |
![]() |
|
Docstrings should be of the format: """Single line summary. Multi-line description. """ |
|
|
This should end with a period and the trailing """" should be on the previous line. |
|
|
Blank line between these. |
|
|
Needs periods. |
|
|
This should say something like "The policy_id field is determines the default scope that is used for the resources. Child … |
|
|
'django_reset' imported but unused |
![]() |
|
'from settings_local import *' used; unable to detect undefined names |
![]() |
|
'PIPELINE_JS' imported but unused |
![]() |
|
'PIPELINE_CSS' imported but unused |
![]() |
|
Col: 1 E402 module level import not at top of file |
![]() |
|
Where this part should be? |
LE lehoangm |

Change Summary:
Combine the verify part of OAuth code into ReviewBoard
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commit: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 2 (+94 -1) |

-
Tool: Pyflakes Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py
-
-
reviewboard/settings.py (Diff revision 2) 'from settings_local import *' used; unable to detect undefined names
-
reviewboard/settings.py (Diff revision 2) Col: 18 E126 continuation line over-indented for hanging indent
-
-
-
-
-
-
Change Summary:
Add scopes to OAUTH2_PROVIDER.SCOPES by walking the WebAPIResource tree and remove useless code about tutorials
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commit: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 3 (+57 -2) |

-
Tool: Pyflakes Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py
-
-
reviewboard/settings.py (Diff revision 3) 'from settings_local import *' used; unable to detect undefined names
-
reviewboard/settings.py (Diff revision 3) Col: 18 E126 continuation line over-indented for hanging indent
-
-
-
-
-
-
-
-
-
-
Change Summary:
correct format errors
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+58 -1) |

-
Tool: Pyflakes Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py
-
-
reviewboard/settings.py (Diff revision 4) 'from settings_local import *' used; unable to detect undefined names
-
-
-
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 5 (+57 -1) |

-
Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py Tool: Pyflakes Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py
-
-
reviewboard/settings.py (Diff revision 5) 'from settings_local import *' used; unable to detect undefined names
-
-
-
-
-
-
reviewboard/settings.py (Diff revision 5) You can use
%
-formatting to build this string more efficiently. -
-
-
-
reviewboard/webapi/base.py (Diff revision 5) You can use
.split(' ', 1)[0]
to get only the first element out. -
Change Summary:
add some docstring
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 6 (+66 -1) |

-
Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py Tool: Pyflakes Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py
-
-
reviewboard/settings.py (Diff revision 6) 'from settings_local import *' used; unable to detect undefined names
-
-
-
-
-
reviewboard/settings.py (Diff revision 6) Docstrings should be of the format:
"""Single line summary. Multi-line description. """
-
reviewboard/webapi/base.py (Diff revision 6) This should end with a period and the trailing
""""
should be on the previous line. -
-
-
reviewboard/webapi/base.py (Diff revision 6) This should say something like
"The
policy_id
field is determines the default scope that is used for the resources. Child classes should override this function to change the default behaviour."
Change Summary:
correct docstrings
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 7 (+70 -1) |

-
Tool: Pyflakes Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/base.py reviewboard/settings.py reviewboard/urls.py
-
-
reviewboard/settings.py (Diff revision 7) 'from settings_local import *' used; unable to detect undefined names
-
-
-
-
Thanks for taking this on, Chenxi! I'm sorry we've been so busy lately. I can tell you our goal is for this to be one of the key features of Review Board 2.6 :)
What work is left to get this out of WIP?
What else would remain for full OAuth2 support? For instance, other OAuth2 providers have a page that a client can pop up that lets the user confirm the client's access, and will then provide the client with a token. Usually that has the provider's logo/name, and the client's logo/name, and a list of things to request for access. Do we have anything for that? I don't know how much the module we're using automatically gives us.