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
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).
108
+
Find the core of the library at ``src/onelogin/saml2``folder.
111
109
112
110
#### Option 2. Download from pypi ####
113
111
@@ -156,13 +154,13 @@ A replay attack is basically try to reuse an intercepted valid SAML Message in o
156
154
SAML Messages have a limited timelife (NotBefore, NotOnOrAfter) that
157
155
make harder this kind of attacks, but they are still possible.
158
156
159
-
In order to avoid them, the SP can keep a list of SAML Messages or Assertion IDs already validated and processed. Those values only need
157
+
In order to avoid them, the SP can keep a list of SAML Messages or Assertion IDs alredy valdidated and processed. Those values only need
160
158
to be stored the amount of time of the SAML Message life time, so
161
159
we don't need to store all processed message/assertion Ids, but the most recent ones.
162
160
163
161
The OneLogin_Saml2_Auth class contains the [get_last_request_id](https://github.com/onelogin/python3-saml/blob/ab62b0d6f3e5ac2ae8e95ce3ed2f85389252a32d/src/onelogin/saml2/auth.py#L357), [get_last_message_id](https://github.com/onelogin/python3-saml/blob/ab62b0d6f3e5ac2ae8e95ce3ed2f85389252a32d/src/onelogin/saml2/auth.py#L364) and [get_last_assertion_id](https://github.com/onelogin/python3-saml/blob/ab62b0d6f3e5ac2ae8e95ce3ed2f85389252a32d/src/onelogin/saml2/auth.py#L371) methods to retrieve the IDs
164
162
165
-
Checking that the ID of the current Message/Assertion does not exists in the list of the ones already processed will prevent replay attacks.
163
+
Checking that the ID of the current Message/Assertion does not exists in the lis of the ones already processed will prevent replay attacks.
166
164
167
165
168
166
Getting Started
@@ -217,31 +215,32 @@ This folder contains a Pyramid project that will be used as demo to show how to
217
215
218
216
This folder contains a Tornado project that will be used as demo to show how to add SAML support to the Tornado Framework. ``views.py`` (with its ``settings.py``) is the main Flask file that has all the code, this file uses the templates stored at the ``templates`` folder. In the ``saml`` folder we found the ``certs`` folder to store the X.509 public and private key, and the SAML toolkit settings (``settings.json`` and ``advanced_settings.json``).
219
217
218
+
It requires python3.8 (it's using tornado 6.4.1)
220
219
221
-
#### setup.py ####
222
-
223
-
Setup script is the centre of all activity in building, distributing, and installing modules.
224
-
Read more at https://pythonhosted.org/an_example_pypi_project/setuptools.html
225
220
226
221
#### tests ####
227
222
228
223
Contains the unit test of the toolkit.
229
224
230
225
In order to execute the test you only need to load the virtualenv with the toolkit installed on it properly:
231
226
```
232
-
pip install -e ".[test]"
227
+
make install-test
233
228
```
234
229
235
230
and execute:
236
231
```
237
-
python setup.py test
232
+
make pytest
238
233
```
239
234
The previous line will run the tests for the whole toolkit. You can also run the tests for a specific module. To do so for the auth module you would have to execute this:
240
235
```
241
-
python setup.py test --test-suite tests.src.OneLogin.saml2_tests.auth_test.OneLogin_Saml2_Auth_Test
With the ``--test-suite`` parameter you can specify the module to test. You'll find all the module available and their class names at ``tests/src/OneLogin/saml2_tests/``.
245
244
246
245
### How It Works ###
247
246
@@ -298,9 +297,9 @@ This is the ``settings.json`` file:
298
297
},
299
298
// If you need to specify requested attributes, set a
300
299
// attributeConsumingService. nameFormat, attributeValue and
301
-
// friendlyName can be omitted
300
+
// friendlyName can be ommited
302
301
"attributeConsumingService": {
303
-
// OPTIONAL: only specify if SP requires this.
302
+
// OPTIONAL: only specifiy if SP requires this.
304
303
// index is an integer which identifies the attributeConsumingService used
305
304
// to the SP. SAML toolkit supports configuring only one attributeConsumingService
306
305
// but in certain cases the SP requires a different value. Defaults to '1'.
@@ -367,7 +366,7 @@ This is the ``settings.json`` file:
367
366
/*
368
367
* Instead of using the whole X.509cert you can use a fingerprint in order to
369
368
* validate a SAMLResponse (but you still need the X.509cert to validate LogoutRequest and LogoutResponse using the HTTP-Redirect binding).
370
-
* But take in mind that the algorithm for the fingerprint should be as strong as the algorithm in a normal certificate signature
369
+
* But take in mind that the algortithm for the fingerprint should be as strong as the algorithm in a normal certificate signature
371
370
* (e.g. SHA256 or strong)
372
371
*
373
372
* (openssl x509 -noout -fingerprint -in "idp.crt" to generate it,
@@ -502,7 +501,7 @@ In addition to the required settings data (idp, sp), extra settings can be defin
502
501
'allowRepeatAttributeName':false,
503
502
504
503
// If the toolkit receive a message signed with a
505
-
// deprecated algorithm (defined at the constant class)
504
+
// deprecated algoritm (defined at the constant class)
506
505
// will raise an error and reject the message
507
506
"rejectDeprecatedAlgorithm":true
508
507
},
@@ -521,7 +520,7 @@ In addition to the required settings data (idp, sp), extra settings can be defin
521
520
},
522
521
523
522
// Organization information template, the info in en_US lang is
auth = OneLogin_Saml2_Auth(req) # Constructor of the SP, loads settings.json
679
678
# and advanced_settings.json
680
679
681
-
auth.login() # This method will build and return a AuthNRequest URL that can be
682
-
# either redirected to, or printed out onto the screen as a hyperlink
680
+
auth.login() # Method that builds and sends the AuthNRequest
683
681
```
684
682
685
683
The ``AuthNRequest`` will be sent signed or unsigned based on the security info of the ``advanced_settings.json`` file (i.e. ``authnRequestsSigned``).
@@ -692,7 +690,7 @@ We can set a ``return_to`` url parameter to the login function and that will be
692
690
target_url ='https://example.com'
693
691
auth.login(return_to=target_url)
694
692
```
695
-
The login method can receive 3 more optional parameters:
693
+
The login method can recieve 3 more optional parameters:
696
694
697
695
*``force_authn`` When ``true``, the ``AuthNReuqest`` will set the ``ForceAuthn='true'``
698
696
*``is_passive`` When true, the ``AuthNReuqest`` will set the ``Ispassive='true'``
@@ -771,7 +769,7 @@ Notice that we saved the user data in the session before the redirection to have
771
769
In order to retrieve attributes we use:
772
770
773
771
```python
774
-
attributes = auth.get_attributes()
772
+
attributes = auth.get_attributes();
775
773
```
776
774
777
775
With this method we get a dict with all the user data provided by the IdP in the assertion of the SAML response.
@@ -787,12 +785,12 @@ If we execute print attributes we could get:
787
785
}
788
786
```
789
787
790
-
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 list of a single element.
788
+
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.
791
789
792
790
The following code is equivalent:
793
791
794
792
```python
795
-
attributes = auth.get_attributes()
793
+
attributes = auth.get_attributes();
796
794
print(attributes['cn'])
797
795
798
796
print(auth.get_attribute('cn'))
@@ -815,7 +813,7 @@ if len(errors) == 0:
815
813
# the value of the url is a trusted URL.
816
814
return redirect(url)
817
815
else:
818
-
print("Successfully Logged out")
816
+
print("Sucessfully Logged out")
819
817
else:
820
818
print("Error when processing SLO: %s%s"% (', '.join(errors), auth.get_last_error_reason()))
821
819
```
@@ -957,7 +955,7 @@ elif 'sls' in request.args: # Single
957
955
# the value of the url is a trusted URL.
958
956
return redirect(url)
959
957
else:
960
-
msg ="Successfully logged out"
958
+
msg ="Sucessfully logged out"
961
959
962
960
iflen(errors) ==0:
963
961
print(msg)
@@ -1073,7 +1071,7 @@ SAML 2 Logout Request class
1073
1071
****get_nameid*** Gets the NameID of the Logout Request Message (returns a string).
1074
1072
****get_issuer*** Gets the Issuer of the Logout Request Message.
1075
1073
****get_session_indexes*** Gets the ``SessionIndexes`` from the Logout Request.
1076
-
****is_valid*** Checks if the Logout Request received is valid.
1074
+
****is_valid*** Checks if the Logout Request recieved is valid.
1077
1075
****get_error*** After execute a validation process, if fails this method returns the cause.
1078
1076
****get_xml*** Returns the XML that will be sent as part of the request or that was received at the SP
1079
1077
@@ -1156,7 +1154,7 @@ Auxiliary class that contains several methods
1156
1154
****get_expire_time*** Compares 2 dates and returns the earliest.
1157
1155
****delete_local_session*** Deletes the local session.
1158
1156
****calculate_X.509_fingerprint*** Calculates the fingerprint of a X.509 cert.
1159
-
****format_finger_print***Formats a fingerprint.
1157
+
****format_finger_print***Formates a fingerprint.
1160
1158
****generate_name_id*** Generates a nameID.
1161
1159
****get_status*** Gets Status from a Response.
1162
1160
****decrypt_element*** Decrypts an encrypted element.
@@ -1206,22 +1204,14 @@ let's see how fast is it to deploy them.
1206
1204
The use of a [virtualenv](http://virtualenv.readthedocs.org/en/latest/) is
1207
1205
highly recommended.
1208
1206
1209
-
Virtualenv helps isolating the python environment used to run the toolkit. You
1207
+
Virtualenv helps isolating the python enviroment used to run the toolkit. You
1210
1208
can find more details and an installation guide in the
Once you have your virtualenv ready and loaded, then you can install the
1214
-
toolkit on it in development mode executing this:
1212
+
toolkit executing this:
1215
1213
```
1216
-
python setup.py develop
1217
-
```
1218
-
1219
-
Using this method of deployment the toolkit files will be linked instead of
1220
-
copied, so if you make changes on them you won't need to reinstall the toolkit.
1221
-
1222
-
If you want install it in a normal mode, execute:
1223
-
```
1224
-
python setup.py install
1214
+
make install-req
1225
1215
```
1226
1216
1227
1217
### Demo Flask ###
@@ -1510,7 +1500,7 @@ Once the SP is configured, the metadata of the SP is published at the ``/metadat
1510
1500
1511
1501
4. We are logged in the app and the user attributes are showed. At this point, we can test the single log out functionality.
1512
1502
1513
-
The single log out functionality could be tested by 2 ways.
1503
+
The single log out funcionality could be tested by 2 ways.
1514
1504
1515
1505
5.1 SLO Initiated by SP. Click on the "logout" link at the SP, after that a Logout Request is sent to the IdP, the session at the IdP is closed and replies through the client to the SP with a Logout Response (sent to the Single Logout Service endpoint). The SLS endpoint /?sls of the SP process the Logout Response and if is valid, close the user session of the local app. Notice that the SLO Workflow starts and ends at the SP.
0 commit comments