Skip to content

Commit 74ffac6

Browse files
committed
Add more docs
1 parent 7033165 commit 74ffac6

3 files changed

Lines changed: 174 additions & 37 deletions

File tree

README.md

Lines changed: 170 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -658,11 +658,165 @@ else:
658658

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

661-
TODO
662-
663-
664-
Demos and test
665-
--------------
661+
####OneLogin_Saml2_Auth - auth.py####
662+
663+
Main class of OneLogin Python Toolkit
664+
665+
* ***__init__*** Initializes the SP SAML instance.
666+
* ***login*** Initiates the SSO process.
667+
* ***logout*** Initiates the SLO process.
668+
* ***process_response*** Process the SAML Response sent by the IdP.
669+
* ***process_slo*** Process the SAML Logout Response / Logout Request sent by the IdP.
670+
* ***redirect_to*** Redirects the user to the url past by parameter or to the url that we defined in our SSO Request.
671+
* ***is_authenticated*** Checks if the user is authenticated or not.
672+
* ***get_attributes*** Returns the set of SAML attributes.
673+
* ***get_attribute*** Returns the requested SAML attribute.
674+
* ***get_nameid*** Returns the nameID.
675+
* ***get_session_index*** Gets the SessionIndex from the AuthnStatement.
676+
* ***get_errors*** Returns a list with code errors if something went wrong.
677+
* ***get_sso_url*** Gets the SSO url.
678+
* ***get_slo_url*** Gets the SLO url.
679+
* ***build_request_signature*** Builds the Signature of the SAML Request.
680+
* ***build_response_signature*** Builds the Signature of the SAML Response.
681+
* ***get_settings*** Returns the settings info.
682+
* ***set_strict*** Set the strict mode active/disable.
683+
684+
####OneLogin_Saml2_Auth - authn_request.py####
685+
686+
SAML 2 Authentication Request class
687+
688+
* ***__init__** This class handles an AuthNRequest. It builds an AuthNRequest object.
689+
* ***get_request*** Returns unsigned AuthnRequest.
690+
* ***get_id*** Returns the AuthNRequest ID.
691+
692+
693+
####OneLogin_Saml2_Response - response.py####
694+
695+
SAML 2 Authentication Response class
696+
697+
* ***__init__*** Constructs the SAML Response object.
698+
* ***is_valid*** Determines if the SAML Response is valid. Includes checking of the signature by a certificate.
699+
* ***check_status*** Check if the status of the response is success or not
700+
* ***get_audiences*** Gets the audiences
701+
* ***get_issuers*** Gets the issuers (from message and from assertion)
702+
* ***get_nameid_data*** Gets the NameID Data provided by the SAML Response from the IdP (returns a dict)
703+
* ***get_nameid*** Gets the NameID provided by the SAML Response from the IdP (returns a string)
704+
* ***get_session_not_on_or_after*** Gets the SessionNotOnOrAfter from the AuthnStatement
705+
* ***get_session_index*** Gets the SessionIndex from the AuthnStatement
706+
* ***get_attributes*** Gets the Attributes from the AttributeStatement element.
707+
* ***validate_num_assertions*** Verifies that the document only contains a single Assertion (encrypted or not)
708+
* ***validate_timestamps*** Verifies that the document is valid according to Conditions Element
709+
* ***get_error*** After execute a validation process, if fails this method returns the cause
710+
711+
####OneLogin_Saml2_LogoutRequest - logout_request.py####
712+
713+
SAML 2 Logout Request class
714+
715+
* ***__init__*** Constructs the Logout Request object.
716+
* ***get_request*** Returns the Logout Request defated, base64encoded.
717+
* ***get_id*** Returns the ID of the Logout Request.
718+
* ***get_nameid_data*** Gets the NameID Data of the the Logout Request (returns a dict).
719+
* ***get_nameid*** Gets the NameID of the Logout Request Message (returns a string).
720+
* ***get_issuer*** Gets the Issuer of the Logout Request Message.
721+
* ***get_session_indexes*** Gets the SessionIndexes from the Logout Request.
722+
* ***is_valid*** Checks if the Logout Request recieved is valid.
723+
* ***get_error*** After execute a validation process, if fails this method returns the cause.
724+
725+
####OneLogin_Saml2_LogoutResponse - logout_response.py####
726+
727+
SAML 2 Logout Response class
728+
729+
* ***__init__*** Constructs a Logout Response object.
730+
* ***get_issuer*** Gets the Issuer of the Logout Response Message
731+
* ***get_status*** Gets the Status of the Logout Response.
732+
* ***is_valid*** Determines if the SAML LogoutResponse is valid
733+
* ***build*** Creates a Logout Response object.
734+
* ***get_response*** Returns a Logout Response object.
735+
* ***get_error*** After execute a validation process, if fails this method returns the cause.
736+
737+
738+
####OneLogin_Saml2_Settings - settings.py####
739+
740+
Configuration of the OneLogin PHP Toolkit
741+
742+
* ***__init__*** Initializes the settings: Sets the paths of the different folders and Loads settings info from settings file or array/object provided.
743+
* ***check_settings*** Checks the settings info.
744+
* ***get_errors*** Returns an array with the errors, the array is empty when the settings is ok.
745+
* ***get_sp_metadata*** Gets the SP metadata. The XML representation.
746+
* ***validate_metadata*** Validates an XML SP Metadata.
747+
* ***get_base_path*** Returns base path.
748+
* ***get_cert_path*** Returns cert path.
749+
* ***get_lib_path*** Returns lib path.
750+
* ***get_ext_lib_path*** Returns external lib path.
751+
* ***get_schemas_path*** Returns schema path.
752+
* ***check_sp_certs*** Checks if the x509 certs of the SP exists and are valid.
753+
* ***get_sp_key*** Returns the x509 private key of the SP.
754+
* ***get_sp_cert*** Returns the x509 public cert of the SP.
755+
* ***get_idp_cert*** Returns the x509 public cert of the IdP.
756+
* ***get_sp_data*** Gets the SP data.
757+
* ***get_idp_data*** Gets the IdP data.
758+
* ***get_security_data*** Gets security data.
759+
* ***get_contacts*** Gets contacts data.
760+
* ***get_organization*** Gets organization data.
761+
* ***format_idp_cert*** Formats the IdP cert.
762+
* ***format_sp_cert*** Formats the SP cert.
763+
* ***format_sp_key*** Formats the private key.
764+
* ***set_strict*** Activates or deactivates the strict mode.
765+
* ***is_strict*** Returns if the 'strict' mode is active.
766+
* ***is_debug_active*** Returns if the debug is active.
767+
768+
####OneLogin_Saml2_Metadata - metadata.py####
769+
770+
A class that contains functionality related to the metadata of the SP
771+
772+
* ***builder*** Generates the metadata of the SP based on the settings.
773+
* ***sign_metadata*** Signs the metadata with the key/cert provided.
774+
* ***add_x509_key_descriptors*** Adds the x509 descriptors (sign/encriptation) to the metadata
775+
776+
####OneLogin_Saml2_Utils - utils.py####
777+
778+
Auxiliary class that contains several methods
779+
780+
* ***decode_base64_and_inflate*** Base64 decodes and then inflates according to RFC1951.
781+
* ***deflate_and_base64_encode*** Deflates and the base64 encodes a string.
782+
* ***validate_xml*** Validates a xml against a schema.
783+
* ***format_cert*** Returns a x509 cert (adding header & footer if required).
784+
* ***format_private_key*** Returns a private key (adding header & footer if required).
785+
* ***redirect*** Executes a redirection to the provided url (or return the target url).
786+
* ***get_self_url_host*** Returns the protocol + the current host + the port (if different than common ports).
787+
* ***get_self_host*** Returns the current host.
788+
* ***is_https*** Checks if https or http.
789+
* ***get_self_url_no_query*** Returns the URL of the current host + current view.
790+
* ***get_self_routed_url_no_query*** Returns the routed URL of the current host + current view.
791+
* ***get_self_url*** Returns the URL of the current host + current view + query.
792+
* ***generate_unique_id*** Generates an unique string (used for example as ID for assertions).
793+
* ***parse_time_to_SAML*** Converts a UNIX timestamp to SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(\.s+)?Z.
794+
* ***parse_SAML_to_time*** Converts a SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(\.s+)?Z to a UNIX timestamp.
795+
* ***now*** Returns unix timestamp of actual time.
796+
* ***parse_duration*** Interprets a ISO8601 duration value relative to a given timestamp.
797+
* ***get_expire_time*** Compares 2 dates and returns the earliest.
798+
* ***query*** Extracts nodes that match the query from the Element.
799+
* ***delete_local_session*** Deletes the local session.
800+
* ***calculate_x509_fingerprint*** Calculates the fingerprint of a x509cert.
801+
* ***format_finger_print*** Formates a fingerprint.
802+
* ***generate_name_id*** Generates a nameID.
803+
* ***get_status*** Gets Status from a Response.
804+
* ***decrypt_element*** Decrypts an encrypted element.
805+
* ***write_temp_file*** Writes some content into a temporary file and returns it.
806+
* ***add_sign*** Adds signature key and senders certificate to an element (Message or Assertion).
807+
* ***validate_sign*** Validates a signature (Message or Assertion).
808+
* ***validate_binary_sign*** Validates signed bynary data (Used to validate GET Signature).
809+
810+
For more info, look at the source code; each method is documented and details about what does and how to use it are provided. Make sure to also check the doc folder where HTML documentation about the classes and methods is provided.
811+
812+
Demos included in the toolkit
813+
-----------------------------
814+
815+
The toolkit includes 2 demos to teach how use the toolkit (A django and a flask project), take a look on it.
816+
Demos require that SP and IdP are well configured before test it, so edit the settings files.
817+
818+
Notice that each python framework has it own way to handle routes/urls and process request, so focus on
819+
how it deployed. New demos using other python frameworks are welcome as a contribution.
666820

667821
### Getting Started ###
668822

@@ -692,7 +846,7 @@ If you want install it in a nomal mode, execute:
692846
python setup.py install
693847
```
694848

695-
#### Demo Flask ####
849+
### Demo Flask ###
696850

697851
You'll need a virtualenv with the toolkit installed on it.
698852

@@ -714,7 +868,14 @@ Now, with the virtualenv loaded, you can run the demo like this:
714868

715869
You'll have the demo running at http://localhost:8000
716870

717-
#### Demo Django ####
871+
####Content####
872+
873+
874+
####How it works####
875+
876+
877+
878+
### Demo Django ###
718879

719880
You'll need a virtualenv with the toolkit installed on it.
720881

@@ -734,32 +895,8 @@ Now, with the virtualenv loaded, you can run the demo like this:
734895

735896
You'll have the demo running at http://localhost:8000
736897

737-
#### Tests Suite ####
738-
739-
To run the test you only need to load the virtualenv with the toolkit installed
740-
on it and execute:
741-
```
742-
python setup.py test
743-
```
744-
745-
The previous line will run the tests for the whole toolkit. You can also run
746-
the tests for a specific module. To do so for the `auth` module you would
747-
have to execute this:
748-
```
749-
python setup.py test --test-suite tests.src.OneLogin.saml2_tests.auth_test.OneLogin_Saml2_Auth_Test
750-
```
751-
752-
With the `--test-suite` parameter you can specify the module to test. You'll
753-
find all the module available and their class names at
754-
`tests/src/OneLogin/saml2_tests/`
755-
756-
757-
### How it works ###
758-
759-
#### Demo Django ####
898+
####Content####
760899

761-
TODO
900+
####How it works####
762901

763-
#### Demo Django ####
764902

765-
TODO

src/onelogin/saml2/metadata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class OneLogin_Saml2_Metadata(object):
3030
@staticmethod
3131
def builder(sp, authnsign=False, wsign=False, valid_until=None, cache_duration=None, contacts=None, organization=None):
3232
"""
33-
Build the metadata of the SP
33+
Builds the metadata of the SP
3434
3535
:param sp: The SP data
3636
:type sp: string
@@ -153,7 +153,7 @@ def builder(sp, authnsign=False, wsign=False, valid_until=None, cache_duration=N
153153
@staticmethod
154154
def sign_metadata(metadata, key, cert):
155155
"""
156-
Sign the metadata with the key/cert provided
156+
Signs the metadata with the key/cert provided
157157
158158
:param metadata: SAML Metadata XML
159159
:type metadata: string
@@ -172,7 +172,7 @@ def sign_metadata(metadata, key, cert):
172172
@staticmethod
173173
def add_x509_key_descriptors(metadata, cert=None):
174174
"""
175-
Add the x509 descriptors (sign/encriptation to the metadata
175+
Adds the x509 descriptors (sign/encriptation) to the metadata
176176
The same cert will be used for sign/encrypt
177177
178178
:param metadata: SAML Metadata XML

src/onelogin/saml2/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ def validate_sign(xml, cert=None, fingerprint=None, validatecert=False, debug=Fa
927927
@staticmethod
928928
def validate_binary_sign(signed_query, signature, cert=None, algorithm=xmlsec.TransformRsaSha1, debug=False):
929929
"""
930-
Validates a GET Signature
930+
Validates signed bynary data (Used to validate GET Signature).
931931
932932
:param signed_query: The element we should validate
933933
:type: string

0 commit comments

Comments
 (0)