Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
feudal
feudalBackend
Commits
1d126a2b
Commit
1d126a2b
authored
Aug 21, 2018
by
Lukas Burgey
Browse files
Add DEBUG_AUTH flag to settings
parent
2235974c
Changes
2
Hide whitespace changes
Inline
Side-by-side
example-config/home/feudal/config/django_settings.py
View file @
1d126a2b
...
...
@@ -7,6 +7,8 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
DEBUG_AUTH
=
False
ALLOWED_HOSTS
=
[
'hdf-portal.data.kit.edu'
,
]
...
...
feudal/backend/auth/v1/views/clients.py
View file @
1d126a2b
# pylint: disable=too-many-return-statements
import
logging
import
re
from
django.contrib.auth.models
import
Group
from
django.http
import
HttpResponse
from
django.conf
import
settings
from
django.contrib.auth
import
authenticate
from
django.contrib.sessions.models
import
Session
from
....
import
models
LOGGER
=
logging
.
getLogger
(
__name__
)
AUTH_DEBUGGING
=
False
ALLOW
=
HttpResponse
(
'allow'
)
DENY
=
HttpResponse
(
'deny'
)
...
...
@@ -144,25 +143,23 @@ def resource_auth_decision(request, decision):
permission
=
request
.
POST
.
get
(
'permission'
,
[])
resource
=
request
.
POST
.
get
(
'resource'
,
''
)
name
=
request
.
POST
.
get
(
'name'
,
''
)
if
not
AUTH_DEBUGGING
:
return
decision
if
decision
==
ALLOW
:
LOGGER
.
debug
(
"[resource] ALLOW %s %s '%s' for %s"
,
permission
,
resource
,
name
,
user
,
)
else
:
LOGGER
.
error
(
"[recource] DENY %s %s '%s' for %s"
,
permission
,
resource
,
name
,
user
,
)
if
settings
.
DEBUG_AUTH
:
if
decision
==
ALLOW
:
LOGGER
.
debug
(
"[resource] ALLOW %s %s '%s' for %s"
,
permission
,
resource
,
name
,
user
,
)
else
:
LOGGER
.
error
(
"[recource] DENY %s %s '%s' for %s"
,
permission
,
resource
,
name
,
user
,
)
return
decision
def
resource_endpoint
(
request
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment