Skip to content

Commit 960cd4a

Browse files
authored
Merge pull request #301 from SAML-Toolkits/lxml_restriction
Update dependencies. Add flake8. Fix code syntax
2 parents 743ad32 + 616ab27 commit 960cd4a

File tree

7 files changed

+47
-36
lines changed

7 files changed

+47
-36
lines changed

.travis.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,27 @@ language: python
22
python:
33
- '2.7'
44

5+
jobs:
6+
include:
7+
- name: "Python 2.7 on Focal Linux"
8+
os: linux
9+
dist: focal
10+
python: 2.7
11+
- name: "Python 2.7 on macOS"
12+
os: osx
13+
python: 2.7
14+
515
install:
616
- sudo apt-get update -qq
717
- sudo apt-get install -qq swig python-dev libxml2-dev libxmlsec1-dev
818
- 'travis_retry pip install .'
919
- 'travis_retry pip install -e ".[test]"'
1020

11-
script:
21+
script:
1222
- 'coverage run --source=src/onelogin/saml2 --rcfile=tests/coverage.rc setup.py test'
1323
- 'coverage report -m --rcfile=tests/coverage.rc'
14-
- 'pycodestyle tests/src/OneLogin/saml2_tests/*.py demo-flask/*.py demo-django/*.py src/onelogin/saml2/*.py --config=tests/pep8.rc'
15-
- 'pyflakes src/onelogin/saml2 demo-django demo-flask tests/src/OneLogin/saml2_tests'
24+
#- 'pycodestyle tests/src/OneLogin/saml2_tests/*.py demo-flask/*.py demo-django/*.py src/onelogin/saml2/*.py --config=tests/pep8.rc'
25+
#- 'pyflakes src/onelogin/saml2 demo-django demo-flask tests/src/OneLogin/saml2_tests'
26+
- flake8 --ignore E226,E302,E41,E731,E501,C901,W504
1627

1728
after_success: 'coveralls'

demo-bottle/index.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def prepare_bottle_request(req):
4444

4545
@app.route('/acs/', method='POST')
4646
@jinja2_view('index.html', template_lookup=['templates'])
47-
def index():
47+
def acs():
4848
req = prepare_bottle_request(request)
4949
auth = init_saml_auth(req)
5050
paint_logout = False
@@ -62,7 +62,7 @@ def index():
6262
self_url = OneLogin_Saml2_Utils.get_self_url(req)
6363
if 'RelayState' in request.forms and self_url != request.forms['RelayState']:
6464
# To avoid 'Open Redirect' attacks, before execute the redirection confirm
65-
# the value of the request.forms['RelayState'] is a trusted URL.
65+
# the value of the request.forms['RelayState'] is a trusted URL.
6666
return redirect(request.forms['RelayState'])
6767

6868
if 'samlUserdata' in session:
@@ -71,10 +71,10 @@ def index():
7171
attributes = session['samlUserdata'].items()
7272

7373
return {
74-
'errors':errors,
75-
'not_auth_warn':not_auth_warn,
76-
'attributes':attributes,
77-
'paint_logout':paint_logout
74+
'errors': errors,
75+
'not_auth_warn': not_auth_warn,
76+
'attributes': attributes,
77+
'paint_logout': paint_logout
7878
}
7979

8080

@@ -124,11 +124,11 @@ def index():
124124
attributes = session['samlUserdata'].items()
125125

126126
return {
127-
'errors':errors,
128-
'not_auth_warn':not_auth_warn,
129-
'success_slo':success_slo,
130-
'attributes':attributes,
131-
'paint_logout':paint_logout
127+
'errors': errors,
128+
'not_auth_warn': not_auth_warn,
129+
'success_slo': success_slo,
130+
'attributes': attributes,
131+
'paint_logout': paint_logout
132132
}
133133

134134

@@ -144,8 +144,8 @@ def attrs():
144144
if len(session['samlUserdata']) > 0:
145145
attributes = session['samlUserdata'].items()
146146

147-
return {'paint_logout':paint_logout,
148-
'attributes':attributes}
147+
return {'paint_logout': paint_logout,
148+
'attributes': attributes}
149149

150150

151151
@app.route('/metadata/')
@@ -178,7 +178,7 @@ def run(self, handler):
178178

179179
if __name__ == "__main__":
180180
# To run HTTPS
181-
#run(SessionMiddleware(app, config=session_opts), host='0.0.0.0', port=8000, debug=True, reloader=True, server=SSLPasteServer)
181+
# run(SessionMiddleware(app, config=session_opts), host='0.0.0.0', port=8000, debug=True, reloader=True, server=SSLPasteServer)
182182

183183
# To run HTTP
184184
run(SessionMiddleware(app, config=session_opts), host='0.0.0.0', port=8000, debug=True, reloader=True, server='paste')

demo-django/demo/urls.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@
99
url(r'^attrs/$', attrs, name='attrs'),
1010
url(r'^metadata/$', metadata, name='metadata')
1111
]
12-

demo-django/demo/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ def index(request):
6464

6565
return HttpResponseRedirect(auth.logout(name_id=name_id, session_index=session_index, nq=name_id_nq, name_id_format=name_id_format, spnq=name_id_spnq))
6666

67-
# If LogoutRequest ID need to be stored in order to later validate it, do instead
67+
# If LogoutRequest ID need to be stored in order to later validate it, do instead
6868
# slo_built_url = auth.logout(name_id=name_id, session_index=session_index)
6969
# request.session['LogoutRequestID'] = auth.get_last_request_id()
70-
#return HttpResponseRedirect(slo_built_url)
70+
# return HttpResponseRedirect(slo_built_url)
7171
elif 'acs' in req['get_data']:
7272
request_id = None
7373
if 'AuthNRequestID' in request.session:
@@ -91,7 +91,7 @@ def index(request):
9191
# the value of the req['post_data']['RelayState'] is a trusted URL.
9292
return HttpResponseRedirect(auth.redirect_to(req['post_data']['RelayState']))
9393
elif auth.get_settings().is_debug_active():
94-
error_reason = auth.get_last_error_reason()
94+
error_reason = auth.get_last_error_reason()
9595
elif 'sls' in req['get_data']:
9696
request_id = None
9797
if 'LogoutRequestID' in request.session:

demo-django/demo/wsgi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
For more information on this file, see
77
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
88
"""
9-
109
import os
11-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings")
12-
1310
from django.core.wsgi import get_wsgi_application
11+
12+
13+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings")
1414
application = get_wsgi_application()

setup.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#! /usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
# Copyright (c) 2010-2021 OneLogin, Inc.
54
# MIT License
65

76
from setuptools import setup
@@ -10,18 +9,20 @@
109
setup(
1110
name='python-saml',
1211
version='2.11.1',
13-
description='Onelogin Python Toolkit. Add SAML support to your Python software using this library',
12+
description='Saml Python Toolkit. Add SAML support to your Python software using this library',
1413
classifiers=[
1514
'Development Status :: 5 - Production/Stable',
1615
'Intended Audience :: Developers',
1716
'Intended Audience :: System Administrators',
1817
'Operating System :: OS Independent',
1918
'Programming Language :: Python :: 2.7',
2019
],
21-
author='OneLogin',
22-
author_email='[email protected]',
20+
author='SAML-Toolkits',
21+
author_email='[email protected]',
22+
maintainer='Sixto Martin',
23+
maintainer_email='[email protected]',
2324
license='MIT',
24-
url='https://github.com/onelogin/python-saml',
25+
url='https://github.com/SAML-Toolkits/python-saml',
2526
packages=['onelogin', 'onelogin/saml2'],
2627
include_package_data=True,
2728
package_data={
@@ -32,17 +33,17 @@
3233
},
3334
test_suite='tests',
3435
install_requires=[
35-
'lxml<4.7.1',
36+
'lxml>=4.6.5, !=4.7.0',
3637
'dm.xmlsec.binding==1.3.7',
3738
'isodate>=0.6.1',
3839
'defusedxml>=0.7.1',
3940
],
4041
extras_require={
4142
'test': (
42-
'coverage>=3.6, <5.0',
43-
'freezegun==0.3.5',
44-
'flake8==3.6.0',
45-
'coveralls==1.1',
43+
'coverage>=5.5, <6.0',
44+
'freezegun>=0.3.5, <0.4',
45+
'flake8>=3.6.0, < 4.0',
46+
'coveralls>=1.1, < 2.0',
4647
),
4748
},
4849
keywords='saml saml2 xmlsec django flask',

src/onelogin/saml2/response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ def is_valid(self, request_data, request_id=None, raise_exceptions=False):
267267
else:
268268
irt = sc_data.get('InResponseTo', None)
269269
if (in_response_to is None and irt is not None and
270-
security.get('rejectUnsolicitedResponsesWithInResponseTo', False)) or \
271-
in_response_to and irt and irt != in_response_to:
270+
security.get('rejectUnsolicitedResponsesWithInResponseTo', False)) \
271+
or in_response_to and irt and irt != in_response_to:
272272
continue
273273
recipient = sc_data.get('Recipient', None)
274274
if recipient and current_url not in recipient:

0 commit comments

Comments
 (0)