-
Notifications
You must be signed in to change notification settings - Fork 819
Fix possible crash in validator when 'client' key is mentioned in request body #1252
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
Open
realsuayip
wants to merge
8
commits into
django-oauth:master
Choose a base branch
from
realsuayip:fix-crash-token-obtain
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+91
−12
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7e628c4
Fix possible crash in validator when 'client' key is mentioned in req…
realsuayip 71d2605
chore: test to demonstrate bug
dopry f450855
fix: token throws an error when client is provided as a string
dopry da0f147
fix: token throws an error when client is provided as a string
dopry 611cd52
chore: complete test coverage
dopry e572389
chore: address copilot feedback.
dopry 0fd1830
chore: copilot comments
dopry effc706
chore: copilot comment
dopry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -202,19 +202,32 @@ def _load_application(self, client_id, request): | |||||
| If request.client was not set, load application instance for given | ||||||
| client_id and store it in request.client | ||||||
| """ | ||||||
|
|
||||||
| # we want to be sure that request has the client attribute! | ||||||
| assert hasattr(request, "client"), '"request" instance has no "client" attribute' | ||||||
|
|
||||||
| if request.client: | ||||||
| """ check for cached client, to save the db hit if this has alredy been loaded """ | ||||||
dopry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| if not isinstance(request.client, Application): | ||||||
| log.debug("request.client is not an Application, something else set request.client erroroneously, resetting request.client.") | ||||||
dopry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| request.client = None | ||||||
| elif request.client.client_id != client_id: | ||||||
| log.debug("request.client client_id does not match the given client_id, resetting request.client.") | ||||||
dopry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| request.client = None | ||||||
| elif not request.client.is_usable(request): | ||||||
| log.debug("request.client is a valid Application, but is not usable, resetting request.client.") | ||||||
dopry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| request.client = None | ||||||
| else: | ||||||
| log.debug("request.client is a valid Application, reusing it.") | ||||||
dopry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| return request.client | ||||||
| try: | ||||||
| request.client = request.client or Application.objects.get(client_id=client_id) | ||||||
| # Check that the application can be used (defaults to always True) | ||||||
| if not request.client.is_usable(request): | ||||||
| log.debug("Failed body authentication: Application %r is disabled" % (client_id)) | ||||||
| """ cache wasn't hit, load from db """ | ||||||
dopry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| log.debug("cache not hit, Loading application from database for client_id %r", client_id) | ||||||
|
||||||
| log.debug("cache not hit, Loading application from database for client_id %r", client_id) | |
| log.debug("cache not hit, loading application from database for client_id %r", client_id) |
dopry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
dopry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
dopry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
dopry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.