Skip to content
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

Fix unhashed secret to work with request body authentication. #1334

Merged
merged 2 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Alan Crosswell
Alejandro Mantecon Guillen
Aleksander Vaskevich
Alessandro De Angelis
Alex Manning
Alex Szabó
Allisson Azevedo
Andrea Greco
Expand Down
2 changes: 1 addition & 1 deletion oauth2_provider/oauth2_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def _authenticate_request_body(self, request):
if self._load_application(client_id, request) is None:
log.debug("Failed body auth: Application %s does not exists" % client_id)
return False
elif not check_password(client_secret, request.client.client_secret):
elif not self._check_secret(client_secret, request.client.client_secret):
log.debug("Failed body auth: wrong client secret %s" % client_secret)
return False
else:
Expand Down
12 changes: 12 additions & 0 deletions tests/test_oauth2_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ def test_authenticate_request_body(self):
self.blank_secret_request.client_secret = "wrong_client_secret"
self.assertFalse(self.validator._authenticate_request_body(self.blank_secret_request))

def test_authenticate_request_body_unhashed_secret(self):
self.application.client_secret = CLEARTEXT_SECRET
self.application.hash_client_secret = False
self.application.save()

self.request.client_id = "client_id"
self.request.client_secret = CLEARTEXT_SECRET
self.assertTrue(self.validator._authenticate_request_body(self.request))

self.application.hash_client_secret = True
self.application.save()

def test_extract_basic_auth(self):
self.request.headers = {"HTTP_AUTHORIZATION": "Basic 123456"}
self.assertEqual(self.validator._extract_basic_auth(self.request), "123456")
Expand Down
Loading