You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update python-saml to 2.1.9, this version includes a security patch that contains extra validations that will prevent signature wrapping attacks.
18
19
19
20
python-saml < v2.1.6 is vulnerable and allows signature wrapping!
20
21
21
-
22
22
#### Security Guidelines ####
23
23
24
24
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.
25
25
26
-
27
26
Why add SAML support to my software?
28
27
------------------------------------
29
28
30
29
SAML is an XML-based standard for web browser single sign-on and is defined by
31
-
the OASIS Security Services Technical Committee. The standard has been around
30
+
the OASIS Security Services Technical Committee. The standard has been around
32
31
since 2002, but lately it is becoming popular due its advantages:
33
32
34
-
***Usability** - One-click access from portals or intranets, deep linking,
33
+
***Usability** - One-click access from portals or intranets, deep linking,
35
34
password elimination and automatically renewing sessions make life
36
35
easier for the user.
37
36
***Security** - Based on strong digital signatures for authentication and
@@ -44,21 +43,21 @@ since 2002, but lately it is becoming popular due its advantages:
44
43
***IT Friendly** - SAML simplifies life for IT because it centralizes
45
44
authentication, provides greater visibility and makes directory
46
45
integration easier.
47
-
***Opportunity** - B2B cloud vendor should support SAML to facilitate the
46
+
***Opportunity** - B2B cloud vendor should support SAML to facilitate the
48
47
integration of their product.
49
48
50
49
General description
51
50
-------------------
52
51
53
-
OneLogin's SAML Python toolkit let you build a SP (Service Provider) over
54
-
your Python application and connect it to any IdP (Identity Provider).
52
+
OneLogin's SAML Python toolkit lets you turn you Python application into an SP
53
+
(Service Provider) that can connect to a IdP (Identity Provider).
***saml2int** - Implements the SAML 2.0 Web Browser SSO Profile.
69
68
***Session-less** - Forget those common conflicts between the SP and
70
69
the final app, the toolkit delegate session in the final app.
71
-
***Easy to use** - Programmer will be allowed to code high-level and
70
+
***Easy to use** - Programmer will be allowed to code high-level and
72
71
low-level programming, 2 easy to use APIs are available.
73
72
***Tested** - Thoroughly tested.
74
73
***Popular** - OneLogin's customers use it. Add easy support to your django/flask/bottle web projects.
@@ -77,7 +76,7 @@ Key features:
77
76
Installation
78
77
------------
79
78
80
-
### Dependences ###
79
+
### Dependencies ###
81
80
82
81
* python 2.7
83
82
*[dm.xmlsec.binding](https://pypi.python.org/pypi/dm.xmlsec.binding) Cython/lxml based binding for the XML security library (depends on python-dev libxml2-dev libxmlsec1-dev)
@@ -87,13 +86,14 @@ Installation
87
86
88
87
Review the setup.py file to know the version of the library that python-saml is using
89
88
90
-
### OSX Dependences ###
89
+
### OSX Dependencies ###
90
+
91
91
* python 2.7
92
92
* libxmlsec1
93
-
93
+
94
94
```sh
95
-
# using brew
96
-
brew install libxmlsec1
95
+
# using brew
96
+
$ brew install libxmlsec1
97
97
```
98
98
99
99
@@ -106,15 +106,15 @@ The toolkit is hosted on github. You can download it from:
Copy the core of the library (src/onelogin/saml2 folder) and merge the setup.py inside the python application. (each application has its structure so take your time to locate the Python SAML toolkit in the best place).
109
+
Copy the core of the library (src/onelogin/saml2 folder) and merge the setup.py inside the python application. (each application has its structure so take your time to locate the Python SAML toolkit in the best place).
110
110
111
111
#### Option 2. Download from pypi ####
112
112
113
113
The toolkit is hosted in pypi, you can find the python-saml package at https://pypi.python.org/pypi/python-saml
114
114
115
115
You can install it executing:
116
116
```
117
-
pip install python-saml
117
+
$ pip install python-saml
118
118
```
119
119
120
120
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)
@@ -123,7 +123,7 @@ If you want to know how a project can handle python packages review this [guide]
123
123
Security warning
124
124
----------------
125
125
126
-
In production, the **strict** parameter MUST be set as **"true"**. Otherwise
126
+
In production, the **strict** parameter MUST be set as **"true"**. Otherwise
127
127
your environment is not secure and will be exposed to attacks.
128
128
129
129
@@ -217,7 +217,7 @@ This is the settings.json file:
217
217
218
218
```javascript
219
219
{
220
-
// If strict is True, then the Python Toolkit will reject unsigned
220
+
// If strict is True, then the Python Toolkit will reject unsigned
221
221
// or unencrypted messages if it expects them to be signed or encrypted.
222
222
// Also it will reject the messages if the SAML standard is not strictly
223
223
// followed. Destination, NameId, Conditions ... are validated too.
@@ -236,11 +236,11 @@ This is the settings.json file:
236
236
// URL Location where the <Response> from the IdP will be returned
237
237
"url":"https://<sp_domain>/?acs",
238
238
// SAML protocol binding to be used when returning the <Response>
239
-
// message. OneLogin Toolkit supports this endpoint for the
239
+
// message. OneLogin Toolkit supports this endpoint for the
// SAML protocol binding to be used when returning the <Response>
@@ -302,16 +302,16 @@ This is the settings.json file:
302
302
// Public x509 certificate of the IdP
303
303
"x509cert":"<onelogin_connector_cert>"
304
304
/*
305
-
* Instead of use the whole x509cert you can use a fingerprint in order to
305
+
* Instead of using the whole x509cert you can use a fingerprint in order to
306
306
* validate a SAMLResponse, but you will need it to validate LogoutRequest and LogoutResponse using the HTTP-Redirect binding.
307
-
*
307
+
*
308
308
* (openssl x509 -noout -fingerprint -in "idp.crt" to generate it,
309
309
* or add for example the -sha256 , -sha384 or -sha512 parameter)
310
310
*
311
311
* If a fingerprint is provided, then the certFingerprintAlgorithm is required in order to
312
312
* let the toolkit know which algorithm was used. Possible values: sha1, sha256, sha384 or sha512
313
313
* 'sha1' is the default value.
314
-
*
314
+
*
315
315
* Notice that if you want to validate any SAML Message sent by the HTTP-Redirect binding, you
316
316
* will need to provide the whole x509cert.
317
317
*/
@@ -321,7 +321,7 @@ This is the settings.json file:
321
321
}
322
322
```
323
323
324
-
In addition to the required settings data (idp, sp), there is extra information that could be defined at advanced_settings.json
324
+
In addition to the required settings data (idp, sp), extra settings can be defined in `advanced_settings.json`:
325
325
326
326
```javascript
327
327
{
@@ -334,15 +334,15 @@ In addition to the required settings data (idp, sp), there is extra information
334
334
// will be encrypted.
335
335
"nameIdEncrypted":false,
336
336
337
-
// Indicates whether the <samlp:AuthnRequest> messages sent by this SP
337
+
// Indicates whether the <samlp:AuthnRequest> messages sent by this SP
338
338
// will be signed. [Metadata of the SP will offer this info]
339
339
"authnRequestsSigned":false,
340
340
341
-
// Indicates whether the <samlp:logoutRequest> messages sent by this SP
341
+
// Indicates whether the <samlp:logoutRequest> messages sent by this SP
342
342
// will be signed.
343
343
"logoutRequestSigned":false,
344
344
345
-
// Indicates whether the <samlp:logoutResponse> messages sent by this SP
345
+
// Indicates whether the <samlp:logoutResponse> messages sent by this SP
346
346
// will be signed.
347
347
"logoutResponseSigned":false,
348
348
@@ -368,7 +368,7 @@ In addition to the required settings data (idp, sp), there is extra information
368
368
// elements received by this SP to be encrypted.
369
369
'wantAssertionsEncrypted'=>false,
370
370
371
-
// Indicates a requirement for the NameID element on the SAMLResponse
371
+
// Indicates a requirement for the NameID element on the SAMLResponse
372
372
// received by this SP to be present.
373
373
"wantNameId":true,
374
374
@@ -428,7 +428,7 @@ In addition to the required settings data (idp, sp), there is extra information
428
428
}
429
429
```
430
430
431
-
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.
431
+
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.
432
432
433
433
Once we know what kind of data could be configured, let's talk about the way settings are handled within the toolkit.
434
434
@@ -557,7 +557,7 @@ auth.get_last_request_id()
557
557
558
558
#### The SP Endpoints ####
559
559
560
-
Related to the SP there are 3 important endpoints: The metadata view, the ACS view and the SLS view.
560
+
Related to the SP there are 3 important endpoints: The metadata view, the ACS view and the SLS view.
561
561
The toolkit provides examples of those views in the demos, but lets see an example.
562
562
563
563
***SP Metadata***
@@ -580,7 +580,7 @@ The get_sp_metadata will return the metadata signed or not based on the security
580
580
581
581
Before the XML metadata is exposed, a check takes place to ensure that the info to be provided is valid.
582
582
583
-
Instead of use the Auth object, you can directly use
583
+
Instead of using the Auth object, you can directly use
@@ -636,7 +636,7 @@ If we execute print attributes we could get:
636
636
"mail": ["Doe"],
637
637
"groups": ["users", "members"]
638
638
}
639
-
```
639
+
```
640
640
641
641
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.
642
642
@@ -679,7 +679,7 @@ if not logout_response.is_valid(self.__request_data, request_id):
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.
@@ -723,7 +723,7 @@ In order to send a Logout Request to the IdP:
723
723
724
724
The Logout Request will be sent signed or unsigned based on the security info of the advanced_settings.json ('logoutRequestSigned').
725
725
726
-
The IdP will return the Logout Response through the user's client to the Single Logout Service of the SP.
726
+
The IdP will return the Logout Response through the user's client to the Single Logout Service of the SP.
727
727
728
728
We can set a 'return_to' url parameter to the logout function and that will be converted as a 'RelayState' parameter:
if'sso'in request.args: # SSO action (SP-SSO initited). Will send an AuthNRequest to the IdP
760
760
return redirect(auth.login())
761
-
elif'sso2'in request.args: # Another SSO init action
761
+
elif'sso2'in request.args: # Another SSO init action
762
762
return_to ='%sattrs/'% request.host_url # but set a custom RelayState URL
763
763
return redirect(auth.login(return_to))
764
764
elif'slo'in request.args: # SLO action. Will sent a Logout Request to IdP
765
765
return redirect(auth.logout())
766
766
elif'acs'in request.args: # Assertion Consumer Service
767
767
auth.process_response() # Process the Response of the IdP
768
768
errors = auth.get_errors() # This method receives an array with the errors
769
-
iflen(errors) ==0: # that could took place during the process
769
+
iflen(errors) ==0: # that could took place during the process
770
770
ifnot auth.is_authenticated(): # This check if the response was ok and the user
771
771
msg ="Not authenticated"# data retrieved or not (user authenticated)
772
772
else:
773
773
request.session['samlUserdata'] = auth.get_attributes() # Retrieves user data
774
774
self_url = OneLogin_Saml2_Utils.get_self_url(req)
775
-
if'RelayState'in request.form and self_url != request.form['RelayState']:
775
+
if'RelayState'in request.form and self_url != request.form['RelayState']:
776
776
return redirect(auth.redirect_to(request.form['RelayState'])) # Redirect if there is a relayState
777
777
else: # If there is user data we save that to print it later.
778
778
msg =''
@@ -875,7 +875,7 @@ SAML 2 Logout Response class
875
875
****get_status*** Gets the Status of the Logout Response.
876
876
****is_valid*** Determines if the SAML LogoutResponse is valid
877
877
****build*** Creates a Logout Response object.
878
-
****get_response*** Returns a Logout Response object.
878
+
****get_response*** Returns a Logout Response object.
879
879
****get_error*** After execute a validation process, if fails this method returns the cause.
880
880
881
881
@@ -915,7 +915,7 @@ Configuration of the OneLogin Python Toolkit
915
915
916
916
A class that contains functionality related to the metadata of the SP
917
917
918
-
****builder*** Generates the metadata of the SP based on the settings.
918
+
****builder*** Generates the metadata of the SP based on the settings.
919
919
****sign_metadata*** Signs the metadata with the key/cert provided.
920
920
****add_x509_key_descriptors*** Adds the x509 descriptors (sign/encriptation) to the metadata
921
921
@@ -1039,7 +1039,7 @@ The flask project contains:
1039
1039
1040
1040
####SP setup####
1041
1041
1042
-
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.
1042
+
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.
1043
1043
1044
1044
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.
1045
1045
@@ -1079,7 +1079,7 @@ To run the demo you need to install the requirements first. Load your
1079
1079
virtualenv and execute:
1080
1080
```
1081
1081
pip install -r demo-django/requirements.txt
1082
-
```
1082
+
```
1083
1083
This will install django and its dependences. Once it has finished, you have to complete the configuration of the toolkit.
1084
1084
1085
1085
Later, with the virtualenv loaded, you can run the demo like this:
@@ -1112,9 +1112,9 @@ The django project contains:
1112
1112
1113
1113
####SP setup####
1114
1114
1115
-
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.
1115
+
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.
1116
1116
1117
-
After set the SAML_FOLDER in the demo/settings.py, the settings of the python toolkit will be loaded on the django web.
1117
+
After set the SAML_FOLDER in the demo/settings.py, the settings of the python toolkit will be loaded on the django web.
1118
1118
1119
1119
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.
0 commit comments