Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simone Rossi
main
Commits
6195ca88
Commit
6195ca88
authored
Dec 07, 2017
by
Daniele Venzano
Browse files
Output user information in logs also for API accesses
parent
9f1a8716
Changes
1
Hide whitespace changes
Inline
Side-by-side
zoe_api/rest_api/utils.py
View file @
6195ca88
...
...
@@ -70,7 +70,7 @@ def get_auth(handler: tornado.web.RequestHandler):
if
handler
.
get_secure_cookie
(
'zoe'
):
cookie_val
=
str
(
handler
.
get_secure_cookie
(
'zoe'
))
uid
,
role
=
cookie_val
[
2
:
-
1
].
split
(
'.'
)
log
.
debug
(
'Authentication done using cookie
'
)
log
.
debug
(
'Authentication done using cookie
(user {} from {} for {})'
.
format
(
uid
,
handler
.
request
.
remote_ip
,
handler
.
request
.
path
)
)
if
role
==
"guest"
:
raise
ZoeRestAPIException
(
'Guest users cannot use the API, ask for a role upgrade'
,
401
,
{
'WWW-Authenticate'
:
'Basic realm="Login Required"'
})
return
uid
,
role
...
...
@@ -95,7 +95,7 @@ def get_auth(handler: tornado.web.RequestHandler):
uid
,
role
=
authenticator
.
auth
(
username
,
password
)
if
uid
is
None
:
raise
ZoeRestAPIException
(
'missing or wrong authentication information'
,
401
,
{
'WWW-Authenticate'
:
'Basic realm="Login Required"'
})
log
.
debug
(
'Authentication done using auth-mechanism
'
)
log
.
debug
(
'Authentication done using auth-mechanism
(user {} from {} for {})'
.
format
(
uid
,
handler
.
request
.
remote_ip
,
handler
.
request
.
path
)
)
if
role
==
"guest"
:
raise
ZoeRestAPIException
(
'Guest users cannot use the API, ask for a role upgrade'
,
401
,
{
'WWW-Authenticate'
:
'Basic realm="Login Required"'
})
...
...
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