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
Jannik Hellenkamp
website
Commits
a0694556
Commit
a0694556
authored
8 years ago
by
Andreas Valder
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of git.fsmpi.rwth-aachen.de:julianundandyfrickelnkram/videoagwebsite
parents
b7f07bef
47afb256
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
+21
-2
21 additions, 2 deletions
server.py
with
21 additions
and
2 deletions
server.py
+
21
−
2
View file @
a0694556
#!/bin/python
from
flask
import
Flask
,
render_template
,
g
,
request
,
url_for
,
redirect
from
flask
import
Flask
,
render_template
,
g
,
request
,
url_for
,
redirect
,
session
import
mysql.connector
import
sqlite3
import
os
import
ldap3
import
re
app
=
Flask
(
__name__
)
config
=
app
.
config
...
...
@@ -34,7 +36,7 @@ def dict_factory(cursor, row):
d
=
{}
for
idx
,
col
in
enumerate
(
cursor
.
description
):
if
type
(
row
[
idx
])
==
str
:
d
[
col
[
0
].
split
(
'
.
'
)[
-
1
]]
=
row
[
idx
].
replace
(
'
\\
n
'
,
'
\n
'
)
d
[
col
[
0
].
split
(
'
.
'
)[
-
1
]]
=
row
[
idx
].
replace
(
'
\\
n
'
,
'
\n
'
)
.
replace
(
'
\\
r
'
,
'
\r
'
)
else
:
d
[
col
[
0
].
split
(
'
.
'
)[
-
1
]]
=
row
[
idx
]
return
d
...
...
@@ -71,6 +73,23 @@ def searchquery(text, columns, match, tables, suffix, *suffixparams):
expr
=
'
SELECT *,SUM(_prio) AS _score FROM (%s) AS _tmp %s
'
%
(
'
UNION
'
.
join
(
subexprs
),
suffix
)
return
query
(
expr
,
*
params
,
*
suffixparams
)
LDAP_USERRE
=
re
.
compile
(
r
'
[^a-z0-9]
'
)
def
ldapauth
(
user
,
password
):
notldap
=
{
'
videoag
'
:(
'
videoag
'
,
[
'
users
'
,
'
videoag
'
]),
'
gustav
'
:(
'
passwort
'
,
[
'
users
'
])}
user
=
LDAP_USERRE
.
sub
(
r
''
,
user
.
lower
())
if
'
LDAP_HOST
'
in
config
:
try
:
conn
=
ldap3
.
Connection
(
config
[
'
LDAP_HOST
'
],
'
uid=%s,ou=users,dc=fsmpi,dc=rwth-aachen,dc=de
'
%
user
,
password
,
auto_bind
=
True
)
if
conn
.
search
(
"
ou=groups,dc=fsmpi,dc=rwth-aachen,dc=de
"
,
"
(&(cn=*)(memberUid=%s))
"
%
user
,
attributes
=
[
'
cn
'
]):
groups
=
[
e
.
cn
.
value
for
e
in
conn
.
entries
]
conn
.
unbind
()
return
user
,
groups
except
ldap3
.
core
.
exceptions
.
LDAPBindError
:
pass
elif
config
.
get
(
'
DEBUG
'
)
and
user
in
notldap
and
password
==
notldap
[
user
][
0
]:
return
user
,
notldap
[
user
][
1
]
return
None
,
[]
@app.route
(
'
/
'
)
def
index
():
return
render_template
(
'
index.html
'
,
latestvideos
=
query
(
'''
...
...
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