Quart SAML integration
Project description
Quart SAML
This Quart extension provides you with an easy way to integrate SAML into your Quart web app.
Installation
Beyond installing the library (e.g. pip install quart_saml) you need to have xmlsec1 installed, e.g. for Ubuntu:
apt-get install xmlsec1
Quickstart
from quart import Quart , url_for,redirect,session
import quart_saml
app = quart.Quart(__name__)
app.config.update({
'SECRET_KEY': 'somethingsecret',
'SAML_METADATA_URL': 'https://mymetadata.xml',
})
quart_saml.QuartSAML(app)
@app.route("/")
async def home():
if "saml" in session:
return "<p>Helo world</p>"
else:
return redirect(url_for("login"))
The SECRET_KEY is required by the default session
storage. The SAML_METADATA_URL is a URL that contains the
SAML metadata which configures the whole app.
Upon successful authentication the user info is stored in session storage under the key 'saml'. The structure of the session data is as follows:
{
'saml': {
'subject': 'user@example.com', # User's unique identifier from the SAML response
'attributes': {} # Additional attributes provided in the SAML assertion
}
}
[!WARNING] The metadata URL should be a HTTPS URL as an untrusted source for metadata will allow an attacker to log in as any user they like.
The extension also sets up the following routes:
/saml/logout/: Log out from the application. This is where users go if they click on a "Logout" button./saml/sso/: Log in through SAML./saml/acs/: After/saml/sso/has sent you to your IdP it sends you back to this path. Also your IdP might provide direct login without needing the/saml/sso/route.
Sending users to login
and logout is as simple as calling quart.url_for('login') and
quart.url_for('logout')
Acknowledgments
This project is based on the Flask-SAML extension. For those looking to integrate SAML with Flask, it serves as an excellent resource.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Quart-SAML-0.1.0.tar.gz.
File metadata
- Download URL: Quart-SAML-0.1.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bf377967314e2dd5c7af5a3e1c0041bc4cd2ce3efadcee7aeac0e1f5a5e711d
|
|
| MD5 |
1104e3883232130d8f0b0f1af1ae3a1a
|
|
| BLAKE2b-256 |
ccf1acc3a6aef1a447ad768d91a011b96f9e84d6e13641019d7bafe6cad65820
|
File details
Details for the file Quart_SAML-0.1.0-py3-none-any.whl.
File metadata
- Download URL: Quart_SAML-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c73ffdfa3452534a7f60838de98fa31eadd4387f806b1fe818d461b89d5aaec
|
|
| MD5 |
603398f86791bfd1acb4b43561560329
|
|
| BLAKE2b-256 |
a3a6da51a690235229eb8e3caa1230a63ba0133932510efe128aebcda0d4bb50
|