An open API service indexing awesome lists of open source software.

https://github.com/ximaz/saml-idp

A Python library to handle SAML Identity Provider side.
https://github.com/ximaz/saml-idp

saml saml-assertion saml-authentication saml-idp saml-metadata saml2

Last synced: about 1 year ago
JSON representation

A Python library to handle SAML Identity Provider side.

Awesome Lists containing this project

README

          

# SAML IdP

Python library to handle SAML requests and to respond with actual SAML responses.

# Example

Python code which handles an SAML Request sent by a Service Provider :

```python
import saml_handler

SAMLRequest = saml_handler.SAMLRequest(saml_request="")

# User authentication <...>
user = { ... }

SAMLResponse = saml_handler.SAMLResponse(saml_request=SAMLRequest, name_id=user["username"])
SAMLResponse.set_field("email", user["email"])
SAMLResponse.set_field("firstname", user["firstname"])
SAMLResponse.set_field("lastname", user["lastname"])
SAMLResponse.set_field("uid", user["username"])

signed_assertion = SAMLResponse.sign("certs/private.key", "certs/public.crt")

# Send assertion to the service provider <...>
```

The XML SAML Response produced by the `saml_handler` :

```xml


[IDENTITY_PROVIDER]






[IDENTITY_PROVIDER]












[SHA-256]



[ASSERTION_SIGNATURE]


[PUBLIC_KEY]





[NAME_ID_VALUE]








[SERVICE_PROVIDER_METADATA_URL]






urn:oasis:names:tc:SAML:2.0:ac:classes:Password






...


...

```