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
Iterations
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
Video AG Infrastruktur
website
Commits
04de45cd
Commit
04de45cd
authored
8 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Add rwthauth endpoint using userinfo.rwth, closes
#36
parent
f45e693a
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
l2pauth.py
+19
-13
19 additions, 13 deletions
l2pauth.py
with
19 additions
and
13 deletions
l2pauth.py
+
19
−
13
View file @
04de45cd
from
server
import
*
import
requests
import
json
from
time
import
sleep
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/
'
...
...
@@ -19,24 +17,32 @@ def oauthget(endpoint, **args):
@app.route
(
'
/l2pauth
'
)
def
start_l2pauth
():
code
=
oauthget
(
'
code
'
,
scope
=
'
l2p2013.rwth
'
)
session
[
'
l2p_oauthcode
'
]
=
code
[
'
device_code
'
]
session
[
'
oauthcode
'
]
=
code
[
'
device_code
'
]
session
[
'
oauthscope
'
]
=
'
l2p
'
return
redirect
(
code
[
'
verification_url
'
]
+
'
?q=verify&d=
'
+
code
[
'
user_code
'
])
@app.route
(
'
/l2p
'
)
def
test_l2pauth
():
return
str
(
session
.
get
(
'
l2p_courses
'
,
{}))
@app.route
(
'
/rwthauth
'
)
def
start_rwthauth
():
code
=
oauthget
(
'
code
'
,
scope
=
'
userinfo.rwth
'
)
session
[
'
oauthcode
'
]
=
code
[
'
device_code
'
]
session
[
'
oauthscope
'
]
=
'
rwth
'
return
redirect
(
code
[
'
verification_url
'
]
+
'
?q=verify&d=
'
+
code
[
'
user_code
'
])
@app.before_request
def
finish_oauth
():
if
'
l2p_
oauthcode
'
not
in
session
:
if
'
oauthcode
'
not
in
session
or
'
oauthscope
'
not
in
session
:
return
token
=
oauthget
(
'
token
'
,
code
=
session
[
'
l2p_
oauthcode
'
],
grant_type
=
'
device
'
)
token
=
oauthget
(
'
token
'
,
code
=
session
[
'
oauthcode
'
],
grant_type
=
'
device
'
)
if
token
.
get
(
'
status
'
)
!=
'
ok
'
:
return
del
session
[
'
l2p_oauthcode
'
]
del
session
[
'
oauthcode
'
]
if
session
[
'
oauthscope
'
]
not
in
[
'
l2p
'
,
'
rwth
'
]:
return
session
[
'
rwthintern
'
]
=
True
if
session
[
'
oauthscope
'
]
==
'
l2p
'
:
session
[
'
l2p_courses
'
]
=
[]
for
course
in
l2pget
(
'
viewAllCourseInfo
'
,
token
[
'
access_token
'
])[
'
dataSet
'
]:
session
[
'
l2p_courses
'
].
append
(
course
[
'
uniqueid
'
])
oauthget
(
'
token
'
,
refresh_token
=
token
[
'
refresh_token
'
],
grant_type
=
'
invalidate
'
)
flash
(
'
Folgende Kurse wurden freigegeben:
'
+
'
,
'
.
join
(
session
[
'
l2p_courses
'
]))
del
session
[
'
oauthscope
'
]
oauthget
(
'
token
'
,
refresh_token
=
token
[
'
refresh_token
'
],
grant_type
=
'
invalidate
'
)
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