Skip to content

Commit 4e5eb13

Browse files
committed
Fix flake8
1 parent 6df62e5 commit 4e5eb13

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

demo-tornado/views.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
import tornado.httputil
66

77
from onelogin.saml2.auth import OneLogin_Saml2_Auth
8-
from onelogin.saml2.settings import OneLogin_Saml2_Settings
98
from onelogin.saml2.utils import OneLogin_Saml2_Utils
109

11-
##Global session info
10+
# Global session info
1211
session = {}
1312

13+
1414
class Application(tornado.web.Application):
1515
def __init__(self):
1616
handlers = [
1717
(r"/", IndexHandler),
1818
(r"/attrs", AttrsHandler),
19-
(r"/metadata",MetadataHandler),
19+
(r"/metadata", MetadataHandler),
2020
]
2121
settings = {
2222
"template_path": Settings.TEMPLATE_PATH,
@@ -55,7 +55,7 @@ def post(self):
5555
if len(session['samlUserdata']) > 0:
5656
attributes = session['samlUserdata'].items()
5757

58-
self.render('index.html',errors=errors,error_reason=error_reason,not_auth_warn=not_auth_warn,success_slo=success_slo,attributes=attributes,paint_logout=paint_logout)
58+
self.render('index.html', errors=errors, error_reason=error_reason, not_auth_warn=not_auth_warn, success_slo=success_slo, attributes=attributes, paint_logout=paint_logout)
5959

6060
def get(self):
6161
req = prepare_tornado_request(self.request)
@@ -99,7 +99,7 @@ def get(self):
9999
error_reason = auth.get_last_error_reason()
100100
elif 'sls' in req['get_data']:
101101
print('-sls-')
102-
dscb = lambda: session.clear() ## clear out the session
102+
dscb = lambda: session.clear() # clear out the session
103103
url = auth.process_slo(delete_session_cb=dscb)
104104
errors = auth.get_errors()
105105
if len(errors) == 0:
@@ -115,7 +115,8 @@ def get(self):
115115
if len(session['samlUserdata']) > 0:
116116
attributes = session['samlUserdata'].items()
117117
print("ATTRIBUTES", attributes)
118-
self.render('index.html',errors=errors,error_reason=error_reason,not_auth_warn=not_auth_warn,success_slo=success_slo,attributes=attributes,paint_logout=paint_logout)
118+
self.render('index.html', errors=errors, error_reason=error_reason, not_auth_warn=not_auth_warn, success_slo=success_slo, attributes=attributes, paint_logout=paint_logout)
119+
119120

120121
class AttrsHandler(tornado.web.RequestHandler):
121122
def get(self):
@@ -127,27 +128,28 @@ def get(self):
127128
if len(session['samlUserdata']) > 0:
128129
attributes = session['samlUserdata'].items()
129130

130-
self.render('attrs.html',paint_logout=paint_logout,attributes=attributes)
131+
self.render('attrs.html', paint_logout=paint_logout, attributes=attributes)
132+
131133

132134
class MetadataHandler(tornado.web.RequestHandler):
133135
def get(self):
134136
req = prepare_tornado_request(self.request)
135137
auth = init_saml_auth(req)
136138
saml_settings = auth.get_settings()
137-
#saml_settings = OneLogin_Saml2_Settings(settings=None, custom_base_path=settings.SAML_FOLDER, sp_validation_only=True)
138139
metadata = saml_settings.get_sp_metadata()
139140
errors = saml_settings.validate_metadata(metadata)
140141

141142
if len(errors) == 0:
142-
#resp = HttpResponse(content=metadata, content_type='text/xml')
143-
self.set_header('Content-Type','text/xml')
143+
# resp = HttpResponse(content=metadata, content_type='text/xml')
144+
self.set_header('Content-Type', 'text/xml')
144145
self.write(metadata)
145146
else:
146-
#resp = HttpResponseServerError(content=', '.join(errors))
147+
# resp = HttpResponseServerError(content=', '.join(errors))
147148
self.write(', '.join(errors))
148-
#return resp
149+
# return resp
149150

150-
def prepare_tornado_request(request):
151+
152+
def prepare_tornado_request(request):
151153

152154
dataDict = {}
153155
for key in request.arguments:
@@ -164,6 +166,7 @@ def prepare_tornado_request(request):
164166
}
165167
return result
166168

169+
167170
def init_saml_auth(req):
168171
auth = OneLogin_Saml2_Auth(req, custom_base_path=Settings.SAML_PATH)
169172
return auth

0 commit comments

Comments
 (0)