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.
- Host: GitHub
- URL: https://github.com/ximaz/saml-idp
- Owner: Ximaz
- Created: 2023-12-14T07:37:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-17T23:28:28.000Z (over 2 years ago)
- Last Synced: 2025-02-05T22:20:01.449Z (over 1 year ago)
- Topics: saml, saml-assertion, saml-authentication, saml-idp, saml-metadata, saml2
- Language: Python
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
...
...
```