Skip to content

Commit 50bf10f

Browse files
committed
Fix README
1 parent 74181e9 commit 50bf10f

1 file changed

Lines changed: 45 additions & 48 deletions

File tree

README.md

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
![PyPi Downloads](https://pypip.in/d/python3-saml/badge.png)
77

88
Add SAML support to your Python software using this library.
9-
Forget those complicated libraries and use that open source library provided
9+
Forget those complicated libraries and use the open source library provided
1010
and supported by OneLogin Inc.
1111

12-
This version supports Python3, exists an alternative version that only support Python2: [python-saml](https://pypi.python.org/pypi/python-saml)
12+
This version supports Python3, There is a separate version that only support Python2: [python-saml](https://pypi.python.org/pypi/python-saml)
1313

1414
Why add SAML support to my software?
1515
------------------------------------
1616

1717
SAML is an XML-based standard for web browser single sign-on and is defined by
18-
the OASIS Security Services Technical Committee. The standard has been around
18+
the OASIS Security Services Technical Committee. The standard has been around
1919
since 2002, but lately it is becoming popular due its advantages:
2020

21-
* **Usability** - One-click access from portals or intranets, deep linking,
21+
* **Usability** - One-click access from portals or intranets, deep linking,
2222
password elimination and automatically renewing sessions make life
2323
easier for the user.
2424
* **Security** - Based on strong digital signatures for authentication and
@@ -31,21 +31,21 @@ since 2002, but lately it is becoming popular due its advantages:
3131
* **IT Friendly** - SAML simplifies life for IT because it centralizes
3232
authentication, provides greater visibility and makes directory
3333
integration easier.
34-
* **Opportunity** - B2B cloud vendor should support SAML to facilitate the
34+
* **Opportunity** - B2B cloud vendor should support SAML to facilitate the
3535
integration of their product.
3636

3737
General description
3838
-------------------
3939

40-
OneLogin's SAML Python toolkit let you build a SP (Service Provider) over
41-
your Python application and connect it to any IdP (Identity Provider).
40+
OneLogin's SAML Python toolkit lets you turn you Python application into an SP
41+
(Service Provider) that can connect to any IdP (Identity Provider).
4242

4343
Supports:
4444

4545
* SSO and SLO (SP-Initiated and IdP-Initiated).
4646
* Assertion and nameId encryption.
47-
* Assertion signature.
48-
* Message signature: AuthNRequest, LogoutRequest, LogoutResponses.
47+
* Assertion signatures.
48+
* Message signatures: AuthNRequest, LogoutRequest, LogoutResponses.
4949
* Enable an Assertion Consumer Service endpoint.
5050
* Enable a Single Logout Service endpoint.
5151
* Publish the SP metadata (which can be signed).
@@ -55,16 +55,15 @@ Key features:
5555
* **saml2int** - Implements the SAML 2.0 Web Browser SSO Profile.
5656
* **Session-less** - Forget those common conflicts between the SP and
5757
the final app, the toolkit delegate session in the final app.
58-
* **Easy to use** - Programmer will be allowed to code high-level and
58+
* **Easy to use** - Programmer will be allowed to code high-level and
5959
low-level programming, 2 easy to use APIs are available.
6060
* **Tested** - Thoroughly tested.
6161
* **Popular** - OneLogin's customers use it. Add easy support to your django/flask web projects.
6262

63-
6463
Installation
6564
------------
6665

67-
### Dependences ###
66+
### Dependencies ###
6867

6968
* python 2.7 // python 3.3
7069
* [xmlsec](https://pypi.python.org/pypi/xmlsec) Python bindings for the XML Security Library.
@@ -89,25 +88,22 @@ The toolkit is hosted in pypi, you can find the python3-saml package at https://
8988

9089
You can install it executing:
9190
```
92-
pip install python3-saml
91+
$ pip install python3-saml
9392
```
9493

9594
If you want to know how a project can handle python packages review this [guide](https://packaging.python.org/en/latest/tutorial.html) and review this [sampleproject](https://github.com/pypa/sampleproject)
9695

97-
9896
Security warning
9997
----------------
10098

101-
In production, the **strict** parameter MUST be set as **"true"**. Otherwise
99+
In production, the **strict** parameter MUST be set as **"true"**. Otherwise
102100
your environment is not secure and will be exposed to attacks.
103101

104-
105102
Security Guidelines
106103
-------------------
107104

108105
If you believe you have discovered a security vulnerability in this toolkit, please report it at https://www.onelogin.com/security with a description. We follow responsible disclosure guidelines, and will work with you to quickly find a resolution.
109106

110-
111107
Getting started
112108
---------------
113109

@@ -187,7 +183,7 @@ This is the settings.json file:
187183

188184
```javascript
189185
{
190-
// If strict is True, then the Python Toolkit will reject unsigned
186+
// If strict is True, then the Python Toolkit will reject unsigned
191187
// or unencrypted messages if it expects them to be signed or encrypted.
192188
// Also it will reject the messages if the SAML standard is not strictly
193189
// followed. Destination, NameId, Conditions ... are validated too.
@@ -206,12 +202,12 @@ This is the settings.json file:
206202
// URL Location where the <Response> from the IdP will be returned
207203
"url": "https://<sp_domain>/?acs",
208204
// SAML protocol binding to be used when returning the <Response>
209-
// message. OneLogin Toolkit supports this endpoint for the
205+
// message. OneLogin Toolkit supports this endpoint for the
210206
// HTTP-POST binding only.
211207
"binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
212208
},
213209
// Specifies info about where and how the <Logout Response> message MUST be
214-
// returned to the requester, in this case our SP.
210+
// returned to the requester, in this case our SP.
215211
"singleLogoutService": {
216212
// URL Location where the <Response> from the IdP will be returned
217213
"url": "https://<sp_domain>/?sls",
@@ -220,7 +216,7 @@ This is the settings.json file:
220216
// only for this endpoint.
221217
"binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
222218
},
223-
// If you need to specify requested attributes, set a
219+
// If you need to specify requested attributes, set a
224220
// attributeConsumingService. nameFormat, attributeValue and
225221
// friendlyName can be ommited
226222
"attributeConsumingService": {
@@ -252,7 +248,7 @@ This is the settings.json file:
252248
"entityId": "https://app.onelogin.com/saml/metadata/<onelogin_connector_id>",
253249
// SSO endpoint info of the IdP. (Authentication Request protocol)
254250
"singleSignOnService": {
255-
// URL Target of the IdP where the Authentication Request Message
251+
// URL Target of the IdP where the Authentication Request Message
256252
// will be sent.
257253
"url": "https://app.onelogin.com/trust/saml2/http-post/sso/<onelogin_connector_id>",
258254
// SAML protocol binding to be used when returning the <Response>
@@ -272,13 +268,14 @@ This is the settings.json file:
272268
// Public x509 certificate of the IdP
273269
"x509cert": "<onelogin_connector_cert>"
274270
/*
275-
* Instead of use the whole x509cert you can use a fingerprint in
271+
* Instead of using the whole x509cert you can use a fingerprint in
276272
* order to validate a SAMLResponse.
277273
* (openssl x509 -noout -fingerprint -in "idp.crt" to generate it,
278274
* or add for example the -sha256 , -sha384 or -sha512 parameter)
279275
*
280276
* If a fingerprint is provided, then the certFingerprintAlgorithm is required in order to
281-
* let the toolkit know which algorithm was used. Possible values: sha1, sha256, sha384 or sha512
277+
* let the toolkit know which algorithm was used.
278+
Possible values: sha1, sha256, sha384 or sha512
282279
* 'sha1' is the default value.
283280
*
284281
* Notice that if you want to validate any SAML Message sent by the HTTP-Redirect binding, you
@@ -290,7 +287,7 @@ This is the settings.json file:
290287
}
291288
```
292289

293-
In addition to the required settings data (idp, sp), there is extra information that could be defined at advanced_settings.json
290+
In addition to the required settings data (idp, sp), extra settings can be defined in `advanced_settings.json`:
294291

295292
```javascript
296293
{
@@ -303,15 +300,15 @@ In addition to the required settings data (idp, sp), there is extra information
303300
// will be encrypted.
304301
"nameIdEncrypted": false,
305302

306-
// Indicates whether the <samlp:AuthnRequest> messages sent by this SP
303+
// Indicates whether the <samlp:AuthnRequest> messages sent by this SP
307304
// will be signed. [Metadata of the SP will offer this info]
308305
"authnRequestsSigned": false,
309306

310-
// Indicates whether the <samlp:logoutRequest> messages sent by this SP
307+
// Indicates whether the <samlp:logoutRequest> messages sent by this SP
311308
// will be signed.
312309
"logoutRequestSigned": false,
313310

314-
// Indicates whether the <samlp:logoutResponse> messages sent by this SP
311+
// Indicates whether the <samlp:logoutResponse> messages sent by this SP
315312
// will be signed.
316313
"logoutResponseSigned": false,
317314

@@ -337,7 +334,7 @@ In addition to the required settings data (idp, sp), there is extra information
337334
// elements received by this SP to be encrypted.
338335
'wantAssertionsEncrypted' => false,
339336

340-
// Indicates a requirement for the NameID element on the SAMLResponse
337+
// Indicates a requirement for the NameID element on the SAMLResponse
341338
// received by this SP to be present.
342339
"wantNameId": true,
343340

@@ -397,7 +394,7 @@ In addition to the required settings data (idp, sp), there is extra information
397394
}
398395
```
399396

400-
In the security section, you can set the way that the SP will handle the messages and assertions. Contact the admin of the IdP and ask him what the IdP expects, and decide what validations will handle the SP and what requirements the SP will have and communicate them to the IdP's admin too.
397+
In the security section, you can set the way that the SP will handle the messages and assertions. Contact the admin of the IdP and ask them what the IdP expects, and decide what validations will handle the SP and what requirements the SP will have and communicate them to the IdP's admin too.
401398

402399
Once we know what kind of data could be configured, let's talk about the way settings are handled within the toolkit.
403400

@@ -520,7 +517,7 @@ The login method can recieve 3 more optional parameters:
520517

521518
#### The SP Endpoints ####
522519

523-
Related to the SP there are 3 important endpoints: The metadata view, the ACS view and the SLS view.
520+
Related to the SP there are 3 important endpoints: The metadata view, the ACS view and the SLS view.
524521
The toolkit provides examples of those views in the demos, but lets see an example.
525522

526523
***SP Metadata***
@@ -543,7 +540,7 @@ The get_sp_metadata will return the metadata signed or not based on the security
543540

544541
Before the XML metadata is exposed, a check takes place to ensure that the info to be provided is valid.
545542

546-
Instead of use the Auth object, you can directly use
543+
Instead of using the Auth object, you can directly use
547544
```
548545
saml_settings = OneLogin_Saml2_Settings(settings=None, custom_base_path=None, sp_validation_only=True)
549546
```
@@ -561,7 +558,7 @@ errors = auth.get_errors()
561558
if not errors:
562559
if auth.is_authenticated():
563560
request.session['samlUserdata'] = auth.get_attributes()
564-
if 'RelayState' in req['post_data'] and
561+
if 'RelayState' in req['post_data'] and
565562
OneLogin_Saml2_Utils.get_self_url(req) != req['post_data']['RelayState']:
566563
auth.redirect_to(req['post_data']['RelayState'])
567564
else:
@@ -599,7 +596,7 @@ If we execute print attributes we could get:
599596
"mail": ["Doe"],
600597
"groups": ["users", "members"]
601598
}
602-
```
599+
```
603600

604601
Each attribute name can be used as a key to obtain the value. Every attribute is a list of values. A single-valued attribute is a listy of a single element.
605602

@@ -642,7 +639,7 @@ if not logout_response.is_valid(self.__request_data, request_id):
642639
elif logout_response.get_status() != OneLogin_Saml2_Constants.STATUS_SUCCESS:
643640
self.__errors.append('logout_not_success')
644641
elif not keep_local_session:
645-
OneLogin_Saml2_Utils.delete_local_session(delete_session_cb)
642+
OneLogin_Saml2_Utils.delete_local_session(delete_session_cb)
646643
```
647644

648645
If the SLS endpoints receives an Logout Request, the request is validated, the session is closed and a Logout Response is sent to the SLS endpoint of the IdP.
@@ -686,7 +683,7 @@ In order to send a Logout Request to the IdP:
686683

687684
The Logout Request will be sent signed or unsigned based on the security info of the advanced_settings.json ('logoutRequestSigned').
688685

689-
The IdP will return the Logout Response through the user's client to the Single Logout Service of the SP.
686+
The IdP will return the Logout Response through the user's client to the Single Logout Service of the SP.
690687

691688
We can set a 'return_to' url parameter to the logout function and that will be converted as a 'RelayState' parameter:
692689

@@ -697,7 +694,7 @@ auth.logout(return_to=target_url)
697694

698695
Also there are 2 optional parameters that can be set:
699696

700-
* name_id. That will be used to build the LogoutRequest. If not name_id parameter is set and the auth object processed a
697+
* name_id. That will be used to build the LogoutRequest. If not name_id parameter is set and the auth object processed a
701698
SAML Response with a NameId, then this NameId will be used.
702699
* session_index. SessionIndex that identifies the session of the user.
703700

@@ -715,21 +712,21 @@ auth = OneLogin_Saml2_Auth(req) # Initialize the SP SAML instance
715712

716713
if 'sso' in request.args: # SSO action (SP-SSO initited). Will send an AuthNRequest to the IdP
717714
return redirect(auth.login())
718-
elif 'sso2' in request.args: # Another SSO init action
715+
elif 'sso2' in request.args: # Another SSO init action
719716
return_to = '%sattrs/' % request.host_url # but set a custom RelayState URL
720717
return redirect(auth.login(return_to))
721718
elif 'slo' in request.args: # SLO action. Will sent a Logout Request to IdP
722719
return redirect(auth.logout())
723720
elif 'acs' in request.args: # Assertion Consumer Service
724721
auth.process_response() # Process the Response of the IdP
725722
errors = auth.get_errors() # This method receives an array with the errors
726-
if len(errors) == 0: # that could took place during the process
723+
if len(errors) == 0: # that could took place during the process
727724
if not auth.is_authenticated(): # This check if the response was ok and the user
728725
msg = "Not authenticated" # data retrieved or not (user authenticated)
729726
else:
730727
request.session['samlUserdata'] = auth.get_attributes() # Retrieves user data
731728
self_url = OneLogin_Saml2_Utils.get_self_url(req)
732-
if 'RelayState' in request.form and self_url != request.form['RelayState']:
729+
if 'RelayState' in request.form and self_url != request.form['RelayState']:
733730
return redirect(auth.redirect_to(request.form['RelayState'])) # Redirect if there is a relayState
734731
else: # If there is user data we save that to print it later.
735732
msg = ''
@@ -831,7 +828,7 @@ SAML 2 Logout Response class
831828
* ***get_status*** Gets the Status of the Logout Response.
832829
* ***is_valid*** Determines if the SAML LogoutResponse is valid
833830
* ***build*** Creates a Logout Response object.
834-
* ***get_response*** Returns a Logout Response object.
831+
* ***get_response*** Returns a Logout Response object.
835832
* ***get_error*** After execute a validation process, if fails this method returns the cause.
836833

837834

@@ -871,7 +868,7 @@ Configuration of the OneLogin Python Toolkit
871868

872869
A class that contains functionality related to the metadata of the SP
873870

874-
* ***builder*** Generates the metadata of the SP based on the settings.
871+
* ***builder*** Generates the metadata of the SP based on the settings.
875872
* ***sign_metadata*** Signs the metadata with the key/cert provided.
876873
* ***add_x509_key_descriptors*** Adds the x509 descriptors (sign/encriptation) to the metadata
877874

@@ -977,7 +974,7 @@ virtualenv and execute:
977974
pip install -r demo-flask/requirements.txt
978975
```
979976

980-
This will install flask and its dependences. Once it has finished, you have to complete the configuration
977+
This will install flask and its dependencies. Once it has finished, you have to complete the configuration
981978
of the toolkit. You'll find it at `demo-flask/settings.json`
982979

983980
Now, with the virtualenv loaded, you can run the demo like this:
@@ -1002,7 +999,7 @@ The flask project contains:
1002999

10031000
####SP setup####
10041001

1005-
The Onelogin's Python Toolkit allows you to provide the settings info in 2 ways: settings files or define a setting dict. In the demo-flask it used the first method.
1002+
The Onelogin's Python Toolkit allows you to provide the settings info in 2 ways: settings files or define a setting dict. In the demo-flask it used the first method.
10061003

10071004
In the index.py file we define the app.config['SAML_PATH'], that will target to the 'saml' folder. We require it in order to load the settings files.
10081005

@@ -1042,8 +1039,8 @@ To run the demo you need to install the requirements first. Load your
10421039
virtualenv and execute:
10431040
```
10441041
pip install -r demo-django/requirements.txt
1045-
```
1046-
This will install django and its dependences. Once it has finished, you have to complete the configuration of the toolkit.
1042+
```
1043+
This will install django and its dependencies. Once it has finished, you have to complete the configuration of the toolkit.
10471044

10481045
Later, with the virtualenv loaded, you can run the demo like this:
10491046
```
@@ -1075,9 +1072,9 @@ The django project contains:
10751072

10761073
####SP setup####
10771074

1078-
The Onelogin's Python Toolkit allows you to provide the settings info in 2 ways: settings files or define a setting dict. In the demo-django it used the first method.
1075+
The Onelogin's Python Toolkit allows you to provide the settings info in 2 ways: settings files or define a setting dict. In the demo-django it used the first method.
10791076

1080-
After set the SAML_FOLDER in the demo/settings.py, the settings of the python toolkit will be loaded on the django web.
1077+
After set the SAML_FOLDER in the demo/settings.py, the settings of the python toolkit will be loaded on the django web.
10811078

10821079
First we need to edit the saml/settings.json, configure the SP part and review the metadata of the IdP and complete the IdP info. Later edit the saml/advanced_settings.json files and configure the how the toolkit will work. Check the settings section of this document if you have any doubt.
10831080

0 commit comments

Comments
 (0)