Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roman Karwacik
website
Commits
697df400
Commit
697df400
authored
8 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Set tracking cookie and reenable logging in auth handler
parent
a21fb14a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.py
+12
-2
12 additions, 2 deletions
server.py
with
12 additions
and
2 deletions
server.py
+
12
−
2
View file @
697df400
...
@@ -516,6 +516,11 @@ def auth(): # For use with nginx auth_request
...
@@ -516,6 +516,11 @@ def auth(): # For use with nginx auth_request
return
'
Internal Server Error
'
,
500
return
'
Internal Server Error
'
,
500
url
=
request
.
headers
[
'
X-Original-Uri
'
].
lstrip
(
config
[
'
VIDEOPREFIX
'
])
url
=
request
.
headers
[
'
X-Original-Uri
'
].
lstrip
(
config
[
'
VIDEOPREFIX
'
])
ip
=
request
.
headers
.
get
(
'
X-Real-IP
'
,
''
)
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
():
if
url
.
endswith
(
'
jpg
'
)
or
ismod
():
return
"
OK
"
,
200
return
"
OK
"
,
200
perms
=
query
(
'''
SELECT videos.path, videos.id AS vid, perm.*
perms
=
query
(
'''
SELECT videos.path, videos.id AS vid, perm.*
...
@@ -535,8 +540,13 @@ def auth(): # For use with nginx auth_request
...
@@ -535,8 +540,13 @@ def auth(): # For use with nginx auth_request
username
=
auth
.
username
username
=
auth
.
username
password
=
auth
.
password
password
=
auth
.
password
if
checkperm
(
perms
,
username
=
username
,
password
=
password
):
if
checkperm
(
perms
,
username
=
username
,
password
=
password
):
return
'
OK
'
,
200
try
:
modify
(
'
INSERT INTO log VALUES (?,
""
, ?,
"
video
"
, ?, ?)
'
,
ip
,
datetime
.
now
(),
perms
[
0
][
'
vid
'
],
url
)
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
password_auth
=
False
for
perm
in
perms
:
for
perm
in
perms
:
if
perm
[
'
type
'
]
==
'
password
'
:
if
perm
[
'
type
'
]
==
'
password
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment