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
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
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
Dominic Meiser
website
Commits
3e232228
Commit
3e232228
authored
3 years ago
by
Nils Beyer
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Remove L2P for authentication
parent
1701046e
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
l2pauth.py
+6
-25
6 additions, 25 deletions
l2pauth.py
server.py
+0
-12
0 additions, 12 deletions
server.py
template_helper.py
+2
-16
2 additions, 16 deletions
template_helper.py
templates/course.html
+0
-1
0 additions, 1 deletion
templates/course.html
templates/macros.html
+4
-20
4 additions, 20 deletions
templates/macros.html
with
12 additions
and
74 deletions
l2pauth.py
+
6
−
25
View file @
3e232228
...
...
@@ -2,15 +2,9 @@ import requests
from
server
import
*
L2P_BASE
=
'
https://www3.elearning.rwth-aachen.de/_vti_bin/l2pservices/api.svc/v1/
'
OAUTH_BASE
=
'
https://oauth.campus.rwth-aachen.de/oauth2waitress/oauth2.svc/
'
MOODLE_BASE
=
'
https://moped.ecampus.rwth-aachen.de/proxy/api/v2/eLearning/Moodle/
'
def
l2pget
(
endpoint
,
token
,
**
args
):
args
[
'
accessToken
'
]
=
token
r
=
requests
.
request
(
'
GET
'
,
L2P_BASE
+
endpoint
,
params
=
args
)
return
r
.
json
()
def
moodleget
(
endpoint
,
token
,
**
args
):
args
[
'
token
'
]
=
token
r
=
requests
.
request
(
'
GET
'
,
MOODLE_BASE
+
endpoint
,
params
=
args
)
...
...
@@ -23,12 +17,7 @@ def oauthget(endpoint, **args):
@app.route
(
'
/internal/l2pauth
'
)
def
start_l2pauth
():
if
'
L2P_APIKEY
'
not
in
config
:
return
render_template
(
"
500.html
"
),
500
code
=
oauthget
(
'
code
'
,
scope
=
'
l2p2013.rwth
'
)
session
[
'
oauthcode
'
]
=
code
[
'
device_code
'
]
session
[
'
oauthscope
'
]
=
'
l2p
'
return
redirect
(
code
[
'
verification_url
'
]
+
'
?q=verify&d=
'
+
code
[
'
user_code
'
])
return
"
L2P is no longer available.
"
@app.route
(
'
/internal/moodleauth
'
)
def
start_moodleauth
():
...
...
@@ -39,6 +28,10 @@ def start_moodleauth():
session
[
'
oauthscope
'
]
=
'
moodle
'
return
redirect
(
code
[
'
verification_url
'
]
+
'
?q=verify&d=
'
+
code
[
'
user_code
'
])
@app.route
(
'
/internal/moodlel2pauth
'
)
def
start_moodlel2pauth
():
return
start_moodleauth
()
@app.route
(
'
/internal/rwthauth
'
)
def
start_rwthauth
():
if
'
L2P_APIKEY
'
not
in
config
:
...
...
@@ -48,15 +41,6 @@ def start_rwthauth():
session
[
'
oauthscope
'
]
=
'
rwth
'
return
redirect
(
code
[
'
verification_url
'
]
+
'
?q=verify&d=
'
+
code
[
'
user_code
'
])
@app.route
(
'
/internal/moodlel2pauth
'
)
def
start_moodlel2pauth
():
if
'
L2P_APIKEY
'
not
in
config
:
return
render_template
(
"
500.html
"
),
500
code
=
oauthget
(
'
code
'
,
scope
=
'
moodle.rwth l2p2013.rwth
'
)
session
[
'
oauthcode
'
]
=
code
[
'
device_code
'
]
session
[
'
oauthscope
'
]
=
'
l2pandmoodle
'
return
redirect
(
code
[
'
verification_url
'
]
+
'
?q=verify&d=
'
+
code
[
'
user_code
'
])
@app.before_request
def
finish_oauth
():
if
'
L2P_APIKEY
'
not
in
config
:
...
...
@@ -67,13 +51,10 @@ def finish_oauth():
if
token
.
get
(
'
status
'
)
!=
'
ok
'
:
return
del
session
[
'
oauthcode
'
]
if
session
[
'
oauthscope
'
]
not
in
[
'
l2p
'
,
'
rwth
'
,
'
moodle
'
,
'
l2pandmoodle
'
]:
return
session
[
'
rwthintern
'
]
=
True
if
session
[
'
oauthscope
'
]
==
'
l2p
'
or
session
[
'
oauthscope
'
]
==
'
l2pandmoodle
'
:
session
[
'
l2p_courses
'
]
=
[]
for
course
in
l2pget
(
'
viewAllCourseInfo
'
,
token
[
'
access_token
'
])[
'
dataSet
'
]:
session
[
'
l2p_courses
'
].
append
(
course
[
'
uniqueid
'
])
if
session
[
'
oauthscope
'
]
==
'
moodle
'
or
session
[
'
oauthscope
'
]
==
'
l2pandmoodle
'
:
data
=
moodleget
(
'
getmyenrolledcourses
'
,
token
[
'
access_token
'
])
if
data
and
data
.
get
(
'
Data
'
):
...
...
This diff is collapsed.
Click to expand it.
server.py
+
0
−
12
View file @
3e232228
...
...
@@ -345,18 +345,6 @@ def lecture(id, course=None, courseid=None): #pylint: disable=unused-argument,to
mode
,
text
=
permdescr
(
perms
)
if
mode
==
'
rwth
'
:
flash
(
text
+
'
. <a target=
"
_blank
"
class=
"
reloadonclose
"
href=
"'
+
url_for
(
'
start_rwthauth
'
)
+
'"
>Hier authorisieren</a>.
'
,
category
=
'
player
'
)
elif
mode
==
'
l2pandmoodle
'
:
if
'
l2p_courses
'
in
session
or
'
moodle_courses
'
in
session
:
flash
(
text
+
'
. Du bist kein Teilnehmer des L2P oder Moodle-Kurses!
\
<a target=
"
_blank
"
class=
"
reloadonclose
"
href=
"'
+
url_for
(
'
start_moodlel2pauth
'
)
+
'"
>Kurse aktualisieren</a>.
'
,
category
=
'
player
'
)
else
:
flash
(
text
+
'
. <a target=
"
_blank
"
class=
"
reloadonclose
"
href=
"'
+
url_for
(
'
start_moodlel2pauth
'
)
+
'"
>Hier authorisieren</a>.
'
,
category
=
'
player
'
)
elif
mode
==
'
l2p
'
:
if
'
l2p_courses
'
in
session
:
flash
(
text
+
'
. Du bist kein Teilnehmer des L2P-Kurses!
\
<a target=
"
_blank
"
class=
"
reloadonclose
"
href=
"'
+
url_for
(
'
start_l2pauth
'
)
+
'"
>Kurse aktualisieren</a>.
'
,
category
=
'
player
'
)
else
:
flash
(
text
+
'
. <a target=
"
_blank
"
class=
"
reloadonclose
"
href=
"'
+
url_for
(
'
start_l2pauth
'
)
+
'"
>Hier authorisieren</a>.
'
,
category
=
'
player
'
)
elif
mode
==
'
moodle
'
:
if
'
moodle_courses
'
in
session
:
flash
(
text
+
'
. Du bist kein Teilnehmer des Moodle-Kurses!
\
...
...
This diff is collapsed.
Click to expand it.
template_helper.py
+
2
−
16
View file @
3e232228
...
...
@@ -133,7 +133,6 @@ def permdescr(perms): #pylint: disable=too-many-branches,too-many-return-stateme
perms
=
evalperm
(
perms
)
public
=
False
password
=
False
l2p_courses
=
[]
moodle_courses
=
[]
rwth_intern
=
False
fsmpi_intern
=
False
...
...
@@ -142,8 +141,6 @@ def permdescr(perms): #pylint: disable=too-many-branches,too-many-return-stateme
public
=
True
elif
perm
[
'
type
'
]
==
'
password
'
:
password
=
True
elif
perm
[
'
type
'
]
==
'
l2p
'
:
l2p_courses
.
append
(
perm
[
'
param1
'
])
elif
perm
[
'
type
'
]
==
'
moodle
'
:
moodle_courses
.
append
(
perm
[
'
param1
'
])
elif
perm
[
'
type
'
]
==
'
rwth
'
:
...
...
@@ -158,21 +155,10 @@ def permdescr(perms): #pylint: disable=too-many-branches,too-many-return-stateme
return
'
rwth
'
,
'
Nur für RWTH-Angehörige verfügbar
'
if
fsmpi_intern
:
return
'
fsmpi
'
,
'
Nur für Fachschaftler verfügbar
'
if
l2p_courses
:
if
password
:
if
moodle_courses
:
return
'
l2pandmoodle
'
,
'
Nur für Teilnehmer der Veranstaltung und Nutzer mit Passwort verfügbar
'
return
'
l2p
'
,
'
Nur für Teilnehmer der Veranstaltung und Nutzer mit Passwort verfügbar
'
if
moodle_courses
:
return
'
l2pandmoodle
'
,
'
Nur für Teilnehmer der Veranstaltung verfügbar
'
return
'
l2p
'
,
'
Nur für Teilnehmer der Veranstaltung verfügbar
'
if
moodle_courses
:
if
password
:
if
l2p_courses
:
return
'
l2pandmoodle
'
,
'
Nur für Teilnehmer der Veranstaltung und Nutzer mit Passwort verfügbar
'
return
'
moodle
'
,
'
Nur für Teilnehmer der Veranstaltung und Nutzer mit Passwort verfügbar
'
if
l2p_courses
:
return
'
l2pandmoodle
'
,
'
Nur für Teilnehmer der Veranstaltung verfügbar
'
else
:
return
'
moodle
'
,
'
Nur für Teilnehmer der Veranstaltung verfügbar
'
if
password
:
return
'
password
'
,
'
Nur für Nutzer mit Passwort verfügbar
'
...
...
This diff is collapsed.
Click to expand it.
templates/course.html
+
0
−
1
View file @
3e232228
...
...
@@ -126,7 +126,6 @@
<option
selected
value=
"password"
>
Passwort
</option>
<option
value=
"rwth"
>
RWTH intern
</option>
<option
value=
"fsmpi"
>
FSMPI intern
</option>
<option
value=
"l2p"
>
L2P Lernraum
</option>
<option
value=
"moodle"
>
Moodle Lernraum
</option>
<option
value=
"none"
>
Kein Zugriff
</option>
</select>
...
...
This diff is collapsed.
Click to expand it.
templates/macros.html
+
4
−
20
View file @
3e232228
...
...
@@ -195,19 +195,11 @@ $(function() {
<a
target=
"_blank"
href=
"{{ url_for('start_rwthauth') }}"
class=
"btn btn-default"
>
Anmelden
</a>
</div>
{% endif %}
{% if
'l2p' in permtypes or
'moodle' in permtypes %}
{% if 'moodle' in permtypes %}
<div
class=
"col-sm-4"
>
<h4
class=
"text-center"
><span
class=
"glyphicon glyphicon-user"
aria-hidden=
"true"
></span>
L2P/
Moodle
</h4>
<h4
class=
"text-center"
><span
class=
"glyphicon glyphicon-user"
aria-hidden=
"true"
></span>
Moodle
</h4>
<p>
Für Teilnehmer der Veranstaltung verfügbar
</p>
{% if 'l2p' in permtypes and not 'moodle' in permtypes %}
{% if not courses_loaded %}
<a
target=
"_blank"
href=
"{{ url_for('start_l2pauth') }}"
class=
"btn btn-default reloadonclose"
>
Anmelden
</a>
{% else %}
<p
class=
"alert alert-info"
>
Du bist kein Teilnehmer des L2P-Kurses!
</p>
<a
target=
"_blank"
href=
"{{ url_for('start_l2pauth') }}"
class=
"btn btn-default reloadonclose"
>
Kurse aktualisieren
</a>
{% endif %}
{% endif %}
{% if 'moodle' in permtypes and not 'l2p' in permtypes %}
{% if 'moodle' in permtypes %}
{% if not courses_loaded %}
<a
target=
"_blank"
href=
"{{ url_for('start_moodleauth') }}"
class=
"btn btn-default reloadonclose"
>
Anmelden
</a>
{% else %}
...
...
@@ -215,18 +207,10 @@ $(function() {
<a
target=
"_blank"
href=
"{{ url_for('start_moodleauth') }}"
class=
"btn btn-default reloadonclose"
>
Kurse aktualisieren
</a>
{% endif %}
{% endif %}
{% if 'moodle' in permtypes and 'l2p' in permtypes %}
{% if not courses_loaded %}
<a
target=
"_blank"
href=
"{{ url_for('start_moodlel2pauth') }}"
class=
"btn btn-default reloadonclose"
>
Anmelden
</a>
{% else %}
<p
class=
"alert alert-info"
>
Du bist kein Teilnehmer des L2P oder Moodle-Kurses!
</p>
<a
target=
"_blank"
href=
"{{ url_for('start_moodlel2pauth') }}"
class=
"btn btn-default reloadonclose"
>
Kurse aktualisieren
</a>
{% endif %}
{% endif %}
</div>
{% endif %}
</div>
{% if
'l2p' not in permtypes and
'moodle' not in permtypes and 'rwth' not in permtypes and 'password' not in permtypes %}
{% if 'moodle' not in permtypes and 'rwth' not in permtypes and 'password' not in permtypes %}
<p
class=
"alert alert-info"
style=
"margin-top: 2em;"
>
Nur für Fachschaftler verfügbar.
</p>
{% endif %}
</div>
...
...
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