Fix security flaw allowing leaking of meta data in the API
Coding bug allows bypassing the API authentication on private servers, to reach the config, network, and build info meta-data endpoints. config and build-info are already public generally, but network meta-data was not.
This commit is contained in:
1 parent
9f21dbcb17
commit
9385dfc27e
1 file changed
+7
-5
+7
-5
@@ -822,18 +822,20 @@ def api_authenticate(request, require_enabled=False):
|
||||
|
||||
try:
|
||||
|
||||
# Force requiring an enabled user when require_login_to_view is set
|
||||
require_enabled = require_enabled or OPENBENCH_CONFIG['require_login_to_view']
|
||||
|
||||
# Don't require a login for Public frameworks
|
||||
if not require_enabled and not OPENBENCH_CONFIG['require_login_to_view']:
|
||||
if not require_enabled:
|
||||
return True
|
||||
|
||||
# Request is made from a browser, and is already logged in
|
||||
if request.user.is_authenticated:
|
||||
return not require_enabled or bool(Profile.objects.get(user=request.user).enabled)
|
||||
return Profile.objects.get(user=request.user).enabled
|
||||
|
||||
# Request might be made from the command line. Check the headers
|
||||
user = django.contrib.auth.authenticate(
|
||||
username=request.POST['username'], password=request.POST['password'])
|
||||
return not require_enabled or Profile.objects.get(user=user).enabled
|
||||
return django.contrib.auth.authenticate(
|
||||
username=request.POST['username'], password=request.POST['password']).enabled
|
||||
|
||||
except Exception:
|
||||
import traceback
|
||||
|
||||
Reference in new issue
Block a user