Skip to content

Commit e46e335

Browse files
committed
docs updated
1 parent 7b427fe commit e46e335

File tree

6 files changed

+104
-181
lines changed

6 files changed

+104
-181
lines changed

README.md

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ This folder contains a Flask project that will be used as demo to show how to ad
172172

173173
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.
174174

175+
#### demo-tornado ####
176+
177+
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``).
175178

176179
#### setup.py ####
177180

@@ -1085,7 +1088,7 @@ For more info, look at the source code. Each method is documented and details ab
10851088
Demos included in the toolkit
10861089
-----------------------------
10871090

1088-
The toolkit includes 2 demos to teach how use the toolkit (A Django and a Flask project), take a look on it.
1091+
The toolkit includes 3 demos to teach how use the toolkit (A Django, Flask and a Tornado project), take a look on it.
10891092
Demos require that SP and IdP are well configured before test it, so edit the settings files.
10901093

10911094
Notice that each python framework has it own way to handle routes/urls and process request, so focus on
@@ -1165,6 +1168,106 @@ First we need to edit the ``saml/settings.json`` file, configure the SP part and
11651168

11661169
Once the SP is configured, the metadata of the SP is published at the ``/metadata`` url. Based on that info, configure the IdP.
11671170

1171+
#### How it works ####
1172+
1173+
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).
1174+
1175+
2. When you click:
1176+
1177+
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.
1178+
1179+
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.
1180+
1181+
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``
1182+
1183+
4. We are logged in the app and the user attributes are showed. At this point, we can test the single log out functionality.
1184+
1185+
The single log out functionality could be tested by 2 ways.
1186+
1187+
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.
1188+
1189+
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.
1190+
1191+
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.
1192+
1193+
### Demo Tornado ###
1194+
1195+
You'll need a virtualenv with the toolkit installed on it.
1196+
1197+
First of all you need some packages, execute:
1198+
```
1199+
apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
1200+
```
1201+
1202+
To run the demo you need to install the requirements first. Load your
1203+
virtualenv and execute:
1204+
```
1205+
pip install -r demo-tornado/requirements.txt
1206+
```
1207+
1208+
1209+
This will install tornado and its dependencies. Once it has finished, you have to complete the configuration
1210+
of the toolkit. You'll find it at `demo-tornado/saml/settings.json`
1211+
1212+
Now, with the virtualenv loaded, you can run the demo like this:
1213+
```
1214+
cd demo-tornado
1215+
python views.py
1216+
```
1217+
1218+
You'll have the demo running at http://localhost:8000
1219+
1220+
#### Content ####
1221+
1222+
The tornado project contains:
1223+
1224+
* ***views.py*** Is the main flask file, where or the SAML handle take place.
1225+
1226+
* ***settings.py*** Contains the base path and the path where is located the ``saml`` folder and the ``template`` folder
1227+
1228+
* ***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.
1229+
1230+
* ***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).
1231+
1232+
#### SP setup ####
1233+
1234+
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.
1235+
1236+
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.
1237+
1238+
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.
1239+
1240+
#### IdP setup ####
1241+
1242+
Once the SP is configured, the metadata of the SP is published at the ``/metadata`` url. Based on that info, configure the IdP.
1243+
1244+
#####Test with keycloack#####
1245+
1246+
You can test your SP with every compatible IdP, for example Keycloack by Red Hat (Check if you need also authorization and not only authentication )
1247+
1248+
###### Install Docker ######
1249+
1250+
Install docker as suggested by [docker guide](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
1251+
1252+
###### Keycloack starting ######
1253+
1254+
First run:
1255+
* docker run --name keycloackContainer -d -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e DB_VENDOR=H2 jboss/keycloak
1256+
1257+
After first run:
1258+
* sudo docker start keycloackContainer
1259+
1260+
Remember to stop keycloack after usage:
1261+
* sudo docker stop keycloackContainer
1262+
1263+
1264+
###### Keycloack useful urls ######
1265+
1266+
* master: http://localhost:8080/auth/admin
1267+
* users: http://localhost:8080/auth/realms/idp_dacd/account/
1268+
* saml request: http://localhost:8080/auth/realms/idp_dacd/protocol/saml
1269+
* metadata: http://localhost:8080/auth/realms/idp_dacd/protocol/saml/descriptor
1270+
11681271
#### How it works ####
11691272

11701273
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).

demo-tornado/Docs/DEVELOPING.md

Lines changed: 0 additions & 82 deletions
This file was deleted.

demo-tornado/requirements.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
Click==7.0
21
defusedxml==0.5.0
32
isodate==0.6.0
4-
itsdangerous==1.1.0
5-
Jinja2==2.10.1
63
lxml==4.3.3
7-
MarkupSafe==1.1.1
84
pkgconfig==1.5.1
95
python3-saml==1.6.0
106
six==1.12.0
117
tornado==6.0.2
12-
Werkzeug==0.15.2
138
xmlsec==1.3.3

demo-tornado/saml/advanced_settings (copia).json

Lines changed: 0 additions & 33 deletions
This file was deleted.

demo-tornado/saml/settings (copia).json

Lines changed: 0 additions & 30 deletions
This file was deleted.

demo-tornado/saml/settings (seconda copia).json

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)