Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
feudal
feudalBackend
Commits
1d126a2b
Commit
1d126a2b
authored
Aug 21, 2018
by
Lukas Burgey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add DEBUG_AUTH flag to settings
parent
2235974c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
21 deletions
+20
-21
example-config/home/feudal/config/django_settings.py
example-config/home/feudal/config/django_settings.py
+2
-0
feudal/backend/auth/v1/views/clients.py
feudal/backend/auth/v1/views/clients.py
+18
-21
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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