Commit a2aea5bf authored by Kiste's avatar Kiste
Browse files

SSO support

parent f227922b
# Stud.FEED
[Stud.FEED](https://git.finf.uni-hannover.de/kiste/studfeed) erstellt einen ATOM-Feed aus allen Veranstaltungen des aktuellen Semesters aus [Stud.IP](http://www.studip.de/) mittels
der [REST-API](https://docs.studip.de/develop/Entwickler/RESTAPI).
[Stud.FEED](https://git.finf.uni-hannover.de/kiste/studfeed) erstellt einen ATOM-Feed aus allen Veranstaltungen des aktuellen Semesters aus [Stud.IP](http://www.studip.de/) mittels der Stud.IP-REST-API.
Damit das Skript auch hinter einem Webserver liegen kann, liegt eine FastCGI-Bridge bei.
......
......@@ -13,6 +13,7 @@ setup(
packages=['studfeed'],
install_requires=[
'feedgen',
'lxml',
'requests'
],
extras_require={
......
......@@ -10,10 +10,13 @@ import argparse
from datetime import datetime
import time
import lxml.html
import requests
from feedgen.feed import FeedGenerator
BASEURL = 'https://studip.uni-hannover.de/api.php'
LOGINURL = 'https://studip.uni-hannover.de/Shibboleth.sso/Login?target=https%3A%2F%2Fstudip.uni-hannover.de%2Findex.php%3Fagain%3Dyes%26sso%3Dshib'
SAMLURL = 'https://studip.uni-hannover.de/Shibboleth.sso/SAML2/POST'
def main():
......@@ -28,8 +31,13 @@ def main():
def generate_feed(user, password, verbose):
with requests.Session() as session:
login = session.get(LOGINURL)
response = session.post(login.url, data={'j_username': user, 'j_password': password})
session.post(SAMLURL, data={x.attrib['name']: x.attrib['value'] for x in lxml.html.fromstring(response.text).xpath(r'//form//input[@type="hidden"]')})
cookie = dict(Seminar_Session=session.cookies['Seminar_Session'])
session = requests.Session()
session.auth = (user, password)
session.cookies = requests.utils.cookiejar_from_dict(cookie)
fg = FeedGenerator()
fg.id('https://studip.uni-hannover.de/')
fg.title('Stud.IP LUH')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment