Skip to content

Commit 37d7388

Browse files
committed
Fix Pylint errors
1 parent cf2b71c commit 37d7388

16 files changed

Lines changed: 383 additions & 190 deletions

.coveralls.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
service_name: travis-ci
2+
3+
src_dir: src

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ __pycache_
1818
/dist
1919
/venv
2020
.coverage
21+
.pypirc
2122

2223
*.key
2324
*.crt

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ install:
1212
script:
1313
- 'coverage run --source=src/onelogin/saml2 --rcfile=tests/coverage.rc setup.py test'
1414
- 'coverage report -m --rcfile=tests/coverage.rc'
15+
- 'pylint src/onelogin/saml2 --rcfile=tests/pylint.rc'
1516
- 'pep8 tests/src/OneLogin/saml2_tests/*.py demo-flask/*.py demo-django/*.py src/onelogin/saml2/*.py --config=tests/pep8.rc'
1617
- 'pyflakes src/onelogin/saml2 demo-django demo-flask tests/src/OneLogin/saml2_tests'
1718

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@
4141
'coveralls==0.4.4',
4242
),
4343
},
44+
keywords='saml saml2 xmlsec django flask',
4445
)

src/onelogin/saml2/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
Copyright (c) 2014, OneLogin, Inc.
5+
All rights reserved.
6+
7+
Add SAML support to your Python softwares using this library.
8+
Forget those complicated libraries and use that open source
9+
library provided and supported by OneLogin Inc.
10+
11+
OneLogin's SAML Python toolkit let you build a SP (Service Provider)
12+
over your Python application and connect it to any IdP (Identity Provider).
13+
14+
Supports:
15+
16+
* SSO and SLO (SP-Initiated and IdP-Initiated).
17+
* Assertion and nameId encryption.
18+
* Assertion signature.
19+
* Message signature: AuthNRequest, LogoutRequest, LogoutResponses.
20+
* Enable an Assertion Consumer Service endpoint.
21+
* Enable a Single Logout Service endpoint.
22+
* Publish the SP metadata (which can be signed).
23+
"""

src/onelogin/saml2/auth.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# -*- coding: utf-8 -*-
22

3-
# Copyright (c) 2014, OneLogin, Inc.
4-
# All rights reserved.
3+
""" OneLogin_Saml2_Auth class
4+
5+
Copyright (c) 2014, OneLogin, Inc.
6+
All rights reserved.
7+
8+
Main class of OneLogin's Python Toolkit.
9+
10+
Initializes the SP SAML instance
11+
12+
"""
513

614
from base64 import b64encode
715
from urllib import quote_plus
@@ -19,6 +27,14 @@
1927

2028

2129
class OneLogin_Saml2_Auth(object):
30+
"""
31+
32+
This class implements the SP SAML instance.
33+
34+
Defines the methods that you can invoke in your application in
35+
order to add SAML support (initiates sso, initiates slo, processes a
36+
SAML Response, a Logout Request or a Logout Response).
37+
"""
2238

2339
def __init__(self, request_data, old_settings=None, custom_base_path=None):
2440
"""

src/onelogin/saml2/authn_request.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# -*- coding: utf-8 -*-
22

3-
# Copyright (c) 2014, OneLogin, Inc.
4-
# All rights reserved.
3+
""" OneLogin_Saml2_Authn_Request class
4+
5+
Copyright (c) 2014, OneLogin, Inc.
6+
All rights reserved.
7+
8+
AuthNRequest class of OneLogin's Python Toolkit.
9+
10+
"""
511

612
from base64 import b64encode
713
from zlib import compress
@@ -10,7 +16,13 @@
1016
from onelogin.saml2.constants import OneLogin_Saml2_Constants
1117

1218

13-
class OneLogin_Saml2_Authn_Request:
19+
class OneLogin_Saml2_Authn_Request(object):
20+
"""
21+
22+
This class handles an AuthNRequest. It builds an
23+
AuthNRequest object.
24+
25+
"""
1426

1527
def __init__(self, settings):
1628
"""
@@ -62,15 +74,16 @@ def __init__(self, settings):
6274
<samlp:RequestedAuthnContext Comparison="exact">
6375
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>
6476
</samlp:RequestedAuthnContext>
65-
</samlp:AuthnRequest>""" % {
66-
'id': uid,
67-
'provider_name': provider_name_str,
68-
'issue_instant': issue_instant,
69-
'destination': destination,
70-
'assertion_url': sp_data['assertionConsumerService']['url'],
71-
'entity_id': sp_data['entityId'],
72-
'name_id_policy': name_id_policy_format,
73-
}
77+
</samlp:AuthnRequest>""" % \
78+
{
79+
'id': uid,
80+
'provider_name': provider_name_str,
81+
'issue_instant': issue_instant,
82+
'destination': destination,
83+
'assertion_url': sp_data['assertionConsumerService']['url'],
84+
'entity_id': sp_data['entityId'],
85+
'name_id_policy': name_id_policy_format,
86+
}
7487

7588
self.__authn_request = request
7689

src/onelogin/saml2/constants.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
# -*- coding: utf-8 -*-
22

3-
# Copyright (c) 2014, OneLogin, Inc.
4-
# All rights reserved.
3+
""" OneLogin_Saml2_Constants class
54
5+
Copyright (c) 2014, OneLogin, Inc.
6+
All rights reserved.
7+
8+
Constants class of OneLogin's Python Toolkit.
9+
10+
"""
11+
12+
13+
class OneLogin_Saml2_Constants(object):
14+
"""
15+
16+
This class defines all the constants that will be used
17+
in the OneLogin's Python Toolkit.
18+
19+
"""
620

7-
class OneLogin_Saml2_Constants:
821
# Value added to the current time in time condition validations
922
ALOWED_CLOCK_DRIFT = 300
1023

src/onelogin/saml2/errors.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
# -*- coding: utf-8 -*-
22

3-
# Copyright (c) 2014, OneLogin, Inc.
4-
# All rights reserved.
3+
""" OneLogin_Saml2_Error class
4+
5+
Copyright (c) 2014, OneLogin, Inc.
6+
All rights reserved.
7+
8+
Error class of OneLogin's Python Toolkit.
9+
10+
Defines common Error codes and has a custom initializator.
11+
12+
"""
513

614

715
class OneLogin_Saml2_Error(Exception):
16+
"""
17+
18+
This class implements a custom Exception handler.
19+
Defines custom error codes.
20+
21+
"""
822

923
# Errors
1024
SETTINGS_FILE_NOT_FOUND = 0

src/onelogin/saml2/logout_request.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# -*- coding: utf-8 -*-
22

3-
# Copyright (c) 2014, OneLogin, Inc.
4-
# All rights reserved.
3+
""" OneLogin_Saml2_Logout_Request class
4+
5+
Copyright (c) 2014, OneLogin, Inc.
6+
All rights reserved.
7+
8+
Logout Request class of OneLogin's Python Toolkit.
9+
10+
"""
511

612
from base64 import b64decode
713
from defusedxml.lxml import fromstring
@@ -13,7 +19,14 @@
1319
from onelogin.saml2.utils import OneLogin_Saml2_Utils
1420

1521

16-
class OneLogin_Saml2_Logout_Request:
22+
class OneLogin_Saml2_Logout_Request(object):
23+
"""
24+
25+
This class handles a Logout Request.
26+
27+
Builds a Logout Response object and validates it.
28+
29+
"""
1730

1831
def __init__(self, settings):
1932
"""
@@ -52,13 +65,14 @@ def __init__(self, settings):
5265
Destination="%(single_logout_url)s">
5366
<saml:Issuer>%(entity_id)s</saml:Issuer>
5467
%(name_id)s
55-
</samlp:LogoutRequest>""" % {
56-
'id': uid,
57-
'issue_instant': issue_instant,
58-
'single_logout_url': idp_data['singleLogoutService']['url'],
59-
'entity_id': sp_data['entityId'],
60-
'name_id': name_id,
61-
}
68+
</samlp:LogoutRequest>""" % \
69+
{
70+
'id': uid,
71+
'issue_instant': issue_instant,
72+
'single_logout_url': idp_data['singleLogoutService']['url'],
73+
'entity_id': sp_data['entityId'],
74+
'name_id': name_id,
75+
}
6276

6377
self.__logout_request = logout_request
6478

0 commit comments

Comments
 (0)