Skip to content

Commit e1db820

Browse files
author
Carlton Duffett
committed
Documented advanced req parameters; Fixed section headers for GitHub-flavored markdown
1 parent 09f6123 commit e1db820

1 file changed

Lines changed: 47 additions & 31 deletions

File tree

README.md

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ This is the settings.json file:
264264
/*
265265
* Key rollover
266266
* If you plan to update the SP x509cert and privateKey
267-
* you can define here the new x509cert and it will be
267+
* you can define here the new x509cert and it will be
268268
* published on the SP metadata so Identity Providers can
269269
* read them and get ready for rollover.
270270
*/
@@ -511,25 +511,31 @@ from onelogin.saml2.utils import OneLogin_Saml2_Utils
511511

512512
#### The Request ####
513513

514-
Building an OneLogin_Saml2_Auth object requires a 'request' parameter.
514+
Building a OneLogin\_Saml2\_Auth object requires a 'request' parameter.
515515

516516
```python
517517
auth = OneLogin_Saml2_Auth(req)
518518
```
519519

520520
This parameter has the following scheme:
521521

522-
```javascript
522+
```python
523523
req = {
524524
"http_host": "",
525525
"script_name": "",
526526
"server_port": "",
527527
"get_data": "",
528-
"post_data": ""
528+
"post_data": "",
529+
530+
/* Advanced request options */
531+
"https": "",
532+
"lowercase_urlencoding": "",
533+
"request_uri": "",
534+
"query_string": ""
529535
}
530536
```
531537

532-
Each python framework built its own request object, you may map its data to match what the saml toolkit expects.
538+
Each python framework builds its own request object, you may map its data to match what the saml toolkit expects.
533539
Let`s see some examples:
534540

535541
```python
@@ -553,6 +559,16 @@ def prepare_from_flask_request(request):
553559
}
554560
```
555561

562+
An explanation of some advanced request parameters:
563+
564+
* `https` - Defaults to "off". Set this to "on" if you receive responses over HTTPS.
565+
566+
* `lowercase_urlencoding` - Defaults to `false`. ADFS users should set this to `true`.
567+
568+
* `request_uri` - The path where your SAML server recieves requests. Set this if requests are not recieved at the server's root.
569+
570+
* `query_string` - Set this with additional query parameters that should be passed to the request endpoint.
571+
556572

557573
#### Initiate SSO ####
558574

@@ -783,7 +799,7 @@ If a match on the LogoutResponse ID and the LogoutRequest ID to be sent is requi
783799
auth.get_last_request_id()
784800
```
785801

786-
####Example of a view that initiates the SSO request and handles the response (is the acs target)####
802+
#### Example of a view that initiates the SSO request and handles the response (is the acs target) ####
787803

788804
We can code a unique file that initiates the SSO process, handle the response, get the attributes, initiate the slo and processes the logout response.
789805

@@ -836,7 +852,7 @@ else:
836852

837853
### SP Key rollover ###
838854

839-
If you plan to update the SP x509cert and privateKey you can define the new x509cert as settings['sp']['x509certNew'] and it will be
855+
If you plan to update the SP x509cert and privateKey you can define the new x509cert as settings['sp']['x509certNew'] and it will be
840856
published on the SP metadata so Identity Providers can read them and get ready for rollover.
841857

842858

@@ -850,7 +866,7 @@ In order to handle that the toolkit offers the settings['idp']['x509certMulti']
850866
When that parameter is used, 'x509cert' and 'certFingerprint' values will be ignored by the toolkit.
851867

852868
The 'x509certMulti' is an array with 2 keys:
853-
- 'signing'. An array of certs that will be used to validate IdP signature
869+
- 'signing'. An array of certs that will be used to validate IdP signature
854870
- 'encryption' An array with one unique cert that will be used to encrypt data to be sent to the IdP.
855871

856872

@@ -865,7 +881,7 @@ Get the ID of the last processed message/assertion with the get_last_message_id/
865881

866882
Described below are the main classes and methods that can be invoked from the SAML2 library.
867883

868-
####OneLogin_Saml2_Auth - auth.py####
884+
#### OneLogin_Saml2_Auth - auth.py ####
869885

870886
Main class of OneLogin Python Toolkit
871887

@@ -896,7 +912,7 @@ Main class of OneLogin Python Toolkit
896912
* ***get_last_assertion_id*** The ID of the last assertion processed.
897913
* ***get_last_assertion_not_on_or_after*** The NotOnOrAfter value of the valid SubjectConfirmationData node (if any) of the last assertion processed (is only calculated with strict = true)
898914

899-
####OneLogin_Saml2_Auth - authn_request.py####
915+
#### OneLogin_Saml2_Auth - authn_request.py ####
900916

901917
SAML 2 Authentication Request class
902918

@@ -905,7 +921,7 @@ SAML 2 Authentication Request class
905921
* ***get_id*** Returns the AuthNRequest ID.
906922
* ***get_xml*** Returns the XML that will be sent as part of the request.
907923

908-
####OneLogin_Saml2_Response - response.py####
924+
#### OneLogin_Saml2_Response - response.py ####
909925

910926
SAML 2 Authentication Response class
911927

@@ -927,7 +943,7 @@ SAML 2 Authentication Response class
927943
* ***get_assertion_id*** the ID of the assertion in the response
928944
* ***get_assertion_not_on_or_after*** the NotOnOrAfter value of the valid SubjectConfirmationData if any
929945

930-
####OneLogin_Saml2_LogoutRequest - logout_request.py####
946+
#### OneLogin_Saml2_LogoutRequest - logout_request.py ####
931947

932948
SAML 2 Logout Request class
933949

@@ -942,7 +958,7 @@ SAML 2 Logout Request class
942958
* ***get_error*** After execute a validation process, if fails this method returns the cause.
943959
* ***get_xml*** Returns the XML that will be sent as part of the request or that was received at the SP
944960

945-
####OneLogin_Saml2_LogoutResponse - logout_response.py####
961+
#### OneLogin_Saml2_LogoutResponse - logout_response.py ####
946962

947963
SAML 2 Logout Response class
948964

@@ -955,7 +971,7 @@ SAML 2 Logout Response class
955971
* ***get_error*** After execute a validation process, if fails this method returns the cause.
956972
* ***get_xml*** Returns the XML that will be sent as part of the response or that was received at the SP
957973

958-
####OneLogin_Saml2_Settings - settings.py####
974+
#### OneLogin_Saml2_Settings - settings.py ####
959975

960976
Configuration of the OneLogin Python Toolkit
961977

@@ -990,15 +1006,15 @@ Configuration of the OneLogin Python Toolkit
9901006
* ***is_strict*** Returns if the 'strict' mode is active.
9911007
* ***is_debug_active*** Returns if the debug is active.
9921008

993-
####OneLogin_Saml2_Metadata - metadata.py####
1009+
#### OneLogin_Saml2_Metadata - metadata.py ####
9941010

9951011
A class that contains functionality related to the metadata of the SP
9961012

9971013
* ***builder*** Generates the metadata of the SP based on the settings.
9981014
* ***sign_metadata*** Signs the metadata with the key/cert provided.
9991015
* ***add_x509_key_descriptors*** Adds the x509 descriptors (sign/encryption) to the metadata
10001016

1001-
####OneLogin_Saml2_Utils - utils.py####
1017+
#### OneLogin_Saml2_Utils - utils.py ####
10021018

10031019
Auxiliary class that contains several methods
10041020

@@ -1030,7 +1046,7 @@ Auxiliary class that contains several methods
10301046
* ***validate_sign*** Validates a signature (Message or Assertion).
10311047
* ***validate_binary_sign*** Validates signed bynary data (Used to validate GET Signature).
10321048

1033-
####OneLogin_Saml2_XML- xml_utils.py####
1049+
#### OneLogin_Saml2_XML- xml_utils.py ####
10341050

10351051
A class that contains methods to handle XMLs
10361052

@@ -1040,7 +1056,7 @@ A class that contains methods to handle XMLs
10401056
* ***query*** Extracts nodes that match the query from the Element
10411057
* ***extract_tag_text***
10421058

1043-
####OneLogin_Saml2_IdPMetadataParser - idp_metadata_parser.py####
1059+
#### OneLogin_Saml2_IdPMetadataParser - idp_metadata_parser.py ####
10441060

10451061
A class that contains methods to obtain and parse metadata from IdP
10461062

@@ -1111,7 +1127,7 @@ Now, with the virtualenv loaded, you can run the demo like this:
11111127

11121128
You'll have the demo running at http://localhost:8000
11131129

1114-
####Content####
1130+
#### Content ####
11151131

11161132
The flask project contains:
11171133

@@ -1123,19 +1139,19 @@ The flask project contains:
11231139
* ***saml*** Is a folder that contains the 'certs' folder that could be used to store the x509 public and private key, and the saml toolkit settings (settings.json and advanced_settings.json).
11241140

11251141

1126-
####SP setup####
1142+
#### SP setup ####
11271143

11281144
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.
11291145

11301146
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.
11311147

11321148
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.
11331149

1134-
####IdP setup####
1150+
#### IdP setup ####
11351151

11361152
Once the SP is configured, the metadata of the SP is published at the /metadata url. Based on that info, configure the IdP.
11371153

1138-
####How it works####
1154+
#### How it works ####
11391155

11401156
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).
11411157

@@ -1180,7 +1196,7 @@ Note that many of the configuration files expect HTTPS. This is not required by
11801196

11811197
If you want to integrate a production django application, take a look on this SAMLServiceProviderBackend that uses our toolkit to add SAML support: https://github.com/KristianOellegaard/django-saml-service-provider
11821198

1183-
####Content####
1199+
#### Content ####
11841200

11851201
The django project contains:
11861202

@@ -1196,23 +1212,23 @@ The django project contains:
11961212

11971213
* ***templates***. Is the folder where django 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.
11981214

1199-
####SP setup####
1215+
#### SP setup ####
12001216

12011217
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.
12021218

12031219
After set the SAML_FOLDER in the demo/settings.py, the settings of the python toolkit will be loaded on the django web.
12041220

12051221
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.
12061222

1207-
####IdP setup####
1223+
#### IdP setup ####
12081224

12091225
Once the SP is configured, the metadata of the SP is published at the /metadata url. Based on that info, configure the IdP.
12101226

1211-
####How it works####
1227+
#### How it works ####
12121228

12131229
This demo works very similar to the flask-demo (We did it intentionally).
12141230

1215-
###Getting up and running on Heroku###
1231+
### Getting up and running on Heroku ###
12161232

12171233
Getting python3-saml up and running on Heroku will require some extra legwork: python3-saml depends on python-xmlsec which depends on headers from the xmlsec1-dev linux package to install correctly.
12181234

@@ -1262,7 +1278,7 @@ Now you can run the demo like this:
12621278

12631279
If that worked, the demo is now running at http://localhost:6543.
12641280

1265-
####Content####
1281+
#### Content ####
12661282

12671283
The Pyramid project contains:
12681284

@@ -1276,19 +1292,19 @@ The Pyramid project contains:
12761292
* ***saml*** is a folder that contains the 'certs' folder that could be used to store the x509 public and private key, and the saml toolkit settings (settings.json and advanced_settings.json).
12771293

12781294

1279-
####SP setup####
1295+
#### SP setup ####
12801296

12811297
The Onelogin's Python Toolkit allows you to provide the settings info in 2 ways: settings files or define a setting dict. In demo_pyramid the first method is used.
12821298

12831299
In the views.py file we define the SAML_PATH, which will target the 'saml' folder. We require it in order to load the settings files.
12841300

12851301
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.
12861302

1287-
####IdP setup####
1303+
#### IdP setup ####
12881304

12891305
Once the SP is configured, the metadata of the SP is published at the /metadata/ url. Based on that info, configure the IdP.
12901306

1291-
####How it works####
1307+
#### How it works ####
12921308

12931309
1. First time you access to the main view 'http://localhost:6543', you can select to login and return to the same view or login and be redirected to /?attrs (attrs view).
12941310

0 commit comments

Comments
 (0)