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 file name to clipboardExpand all lines: README.md
+79-1Lines changed: 79 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -174,6 +174,11 @@ This folder contains a Flask project that will be used as demo to show how to ad
174
174
175
175
This folder contains a Pyramid project that will be used as demo to show how to add SAML support to the [Pyramid Web Framework](http://docs.pylonsproject.org/projects/pyramid/en/latest/). ``\_\_init__.py`` is the main file that configures the app and its routes, ``views.py`` is where all the logic and SAML handling takes place, and the templates are stored in the ``templates`` folder. The ``saml`` folder is the same as in the other two demos.
176
176
177
+
#### demo-tornado ####
178
+
179
+
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``).
180
+
181
+
It requires python3.5 (it's using tornado 6.0.3)
177
182
178
183
#### setup.py ####
179
184
@@ -1097,7 +1102,7 @@ For more info, look at the source code. Each method is documented and details ab
1097
1102
Demos included in the toolkit
1098
1103
-----------------------------
1099
1104
1100
-
The toolkit includes 2 demos to teach how use the toolkit (A Djangoand a Flask project), take a look on it.
1105
+
The toolkit includes 3 demos to teach how use the toolkit (A Django, Flask and a Tornado project), take a look on it.
1101
1106
Demos require that SP and IdP are well configured before test it, so edit the settings files.
1102
1107
1103
1108
Notice that each python framework has it own way to handle routes/urls and process request, so focus on
@@ -1177,6 +1182,79 @@ First we need to edit the ``saml/settings.json`` file, configure the SP part and
1177
1182
1178
1183
Once the SP is configured, the metadata of the SP is published at the ``/metadata`` url. Based on that info, configure the IdP.
1179
1184
1185
+
#### How it works ####
1186
+
1187
+
1. First time you access to the main view (http://localhost:8000), you can select to login and return to the same view or login and be redirected to ``/?attrs`` (attrs view).
1188
+
1189
+
2. When you click:
1190
+
1191
+
2.1 in the first link, we access to ``/?sso`` (index view). An ``AuthNRequest`` is sent to the IdP, we authenticate at the IdP and then a Response is sent through the user's client to the SP, specifically the Assertion Consumer Service view: ``/?acs``. Notice that a ``RelayState`` parameter is set to the url that initiated the process, the index view.
1192
+
1193
+
2.2 in the second link we access to ``/?attrs`` (attrs view), we will expetience have the same process described at 2.1 with the diference that as ``RelayState`` is set the ``attrs`` url.
1194
+
1195
+
3. The SAML Response is processed in the ACS ``/?acs``, if the Response is not valid, the process stops here and a message is shown. Otherwise we are redirected to the ``RelayState`` view. a) / or b) ``/?attrs``
1196
+
1197
+
4. We are logged in the app and the user attributes are showed. At this point, we can test the single log out functionality.
1198
+
1199
+
The single log out functionality could be tested by 2 ways.
1200
+
1201
+
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.
1202
+
1203
+
5.2 SLO Initiated by IdP. In this case, the action takes place on the IdP side, the logout process is initiated at the IdP, sends a Logout Request to the SP (SLS endpoint, ``/?sls``). The SLS endpoint of the SP process the Logout Request and if is valid, close the session of the user at the local app and send a Logout Response to the IdP (to the SLS endpoint of the IdP). The IdP receives the Logout Response, process it and close the session at of the IdP. Notice that the SLO Workflow starts and ends at the IdP.
1204
+
1205
+
Notice that all the SAML Requests and Responses are handled at a unique view (index) and how GET parameters are used to know the action that must be done.
1206
+
1207
+
### Demo Tornado ###
1208
+
1209
+
You'll need a virtualenv with the toolkit installed on it.
To run the demo you need to install the requirements first. Load your
1217
+
virtualenv and execute:
1218
+
```
1219
+
pip install -r demo-tornado/requirements.txt
1220
+
```
1221
+
1222
+
1223
+
This will install tornado and its dependencies. Once it has finished, you have to complete the configuration
1224
+
of the toolkit. You'll find it at `demo-tornado/saml/settings.json`
1225
+
1226
+
Now, with the virtualenv loaded, you can run the demo like this:
1227
+
```
1228
+
cd demo-tornado
1229
+
python views.py
1230
+
```
1231
+
1232
+
You'll have the demo running at http://localhost:8000
1233
+
1234
+
#### Content ####
1235
+
1236
+
The tornado project contains:
1237
+
1238
+
****views.py*** Is the main flask file, where or the SAML handle take place.
1239
+
1240
+
****settings.py*** Contains the base path and the path where is located the ``saml`` folder and the ``template`` folder
1241
+
1242
+
****templates***. Is the folder where tornado stores the templates of the project. It was implemented a base.html template that is extended by index.html and attrs.html, the templates of our simple demo that shows messages, user attributes when available and login and logout links.
1243
+
1244
+
****saml*** Is a folder that contains the 'certs' folder that could be used to store the X.509 public and private key, and the saml toolkit settings (settings.json and advanced_settings.json).
1245
+
1246
+
#### SP setup ####
1247
+
1248
+
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-tornado``, it uses the first method.
1249
+
1250
+
In the ``settings.py`` file we define the ``SAML_PATH``, that will target to the ``saml`` folder. We require it in order to load the settings files.
1251
+
1252
+
First we need to edit the ``saml/settings.json`` file, 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.
1253
+
1254
+
#### IdP setup ####
1255
+
1256
+
Once the SP is configured, the metadata of the SP is published at the ``/metadata`` url. Based on that info, configure the IdP.
1257
+
1180
1258
#### How it works ####
1181
1259
1182
1260
1. First time you access to the main view (http://localhost:8000), you can select to login and return to the same view or login and be redirected to ``/?attrs`` (attrs view).
0 commit comments