Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Video AG Infrastruktur
website
Commits
697df400
Commit
697df400
authored
Feb 16, 2017
by
Julian Rother
Browse files
Set tracking cookie and reenable logging in auth handler
parent
a21fb14a
Changes
1
Hide whitespace changes
Inline
Side-by-side
server.py
View file @
697df400
...
...
@@ -516,6 +516,11 @@ def auth(): # For use with nginx auth_request
return
'Internal Server Error'
,
500
url
=
request
.
headers
[
'X-Original-Uri'
].
lstrip
(
config
[
'VIDEOPREFIX'
])
ip
=
request
.
headers
.
get
(
'X-Real-IP'
,
''
)
if
'tracking'
in
request
.
cookies
:
cookie
=
request
.
cookies
[
'tracking'
]
else
:
cookie
=
''
.
join
(
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
_
in
range
(
64
))
# r.set_cookie('tracking', request.cookies.get('tracking', ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(64))), max_age=2147483647)
if
url
.
endswith
(
'jpg'
)
or
ismod
():
return
"OK"
,
200
perms
=
query
(
'''SELECT videos.path, videos.id AS vid, perm.*
...
...
@@ -535,8 +540,13 @@ def auth(): # For use with nginx auth_request
username
=
auth
.
username
password
=
auth
.
password
if
checkperm
(
perms
,
username
=
username
,
password
=
password
):
return
'OK'
,
200
modify
(
'INSERT INTO log VALUES (?, "", ?, "video", ?, ?)'
,
ip
,
datetime
.
now
(),
perms
[
0
][
'vid'
],
url
)
try
:
modify
(
'INSERT INTO log VALUES (?, ?, ?, "video", ?, ?)'
,
ip
,
cookie
,
datetime
.
now
(),
perms
[
0
][
'vid'
],
url
)
except
:
pass
r
=
make_response
(
'OK'
,
200
)
r
.
set_cookie
(
'tracking'
,
cookie
,
max_age
=
2147483647
)
# Many many years
return
r
password_auth
=
False
for
perm
in
perms
:
if
perm
[
'type'
]
==
'password'
:
...
...
Write
Preview
Supports
Markdown
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