跳转到主要内容

最小化SAML2客户端

项目描述

MiniSAML

Code style: black CircleCI Documentation Status

绝对最小化SAML 2客户端。故意不支持完整的SAML 2规范。它只支持通过HTTP Redirect发送请求和通过HTTP POST发送响应。

用法

创建SAML请求

from minisaml.request import get_request_redirect_url

url = get_request_redirect_url(
    saml_endpoint="https://your-idp.invalid/sso-endpoint/",
    expected_audience="Your SAML Issuer",
    acs_url="https://you.web-site.invalid/saml/acs/"
)

# This line depends on your web framework/server
redirect_user_to_url(url)

验证和解析SAML响应

from minisaml.response import validate_response

# This line depends on your web framework/server
saml_response = get_SAMLResponse_form_data_as_bytes()

# Load the x509 certificate as a cryptography.x509.Certificate somehow
certificate = ...

try:
    response = validate_response(
        data=saml_response,
        certificate=certificate,
        expected_audience="Your SAML Issuer",
        idp_issuer="https://your-idp.invalid/issuer/"
    )
except:
    handle_invalid_response_somehow()

# response is a minisaml.response.Response object

项目详情


下载文件

下载适用于您平台文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

minisaml-24.6.tar.gz (6.4 kB 查看哈希值)

上传时间 源代码

构建分发

minisaml-24.6-py3-none-any.whl (7.8 kB 查看哈希值)

上传时间 Python 3

支持