saml2.0的服务提供程序实现。

pysamlsp的Python项目详细描述


pysamlsp是一个python库,用于在saml2.0 sso环境中实现服务提供者。

此软件包正在积极开发中,但目前尚未完成。请不要试图使用它。

要求

python包

  • python设置工具
  • Python2.7
  • lxml

对于测试:

  • 鼻子
  • 预期值
  • 丁格斯

非python包

  • xmlsec1
  • openssl(尽管xmlsec1可以用gnutls、libgcrypt或nss构建)
  • libxml2
  • libxslt

安装

在这个开发阶段,我还没有上传到Pypi一旦我有了,安装将像:

pip install pysqlsp

同时,您可以克隆此存储库并运行:

python setup.py install

用法

使用配置字典初始化类:

sp_config = dict( ... )

配置字典可能包含以下条目:

  • ‘assertion_consumer_service_url’: The URL of the SSO provider.
  • ‘issuer’: A unique identifier for the service provider; probably should match the entityID attribute of the SP metadata.
  • ‘private_key’: A path for the private key PEM file, required for signing AuthnRequests.
  • ‘sign_authnrequests’: True / False flag to indicate whether AuthnRequests should be signed.
  • ‘certificate’: A path for the certificate file against which a SAMLResponse signature can be verified.

使用samlrequest查询参数创建重定向url:

sp = Pysamlsp(sp_config)
redirect_url = sp.redirect_for_idp()

标识提供程序将投递到service providers metadata.xml中指定的地址。发布字段“samlResponse”将包含(base64encoded,gzip'd)XML响应:

saml_response = query['SAMLResponse']
if sp.idp_response_is_valid(saml_response):
  ...

签名的authnrequests

如果要签署authnrequests,则需要rsa私钥。下面是使用openssl创建密钥的过程

创建私钥,有效期10年:

openssl req -x509 -days 3650 -newkey rsa:1024 -keyout saml_key_pw.pem -out saml.crt

从新密钥中删除密码短语。此库当前不支持带有密码短语的密钥:

openssl rsa -in saml_key_pw.pem -out saml_key.pem

从私钥创建公钥。您将需要此元数据:

openssl rsa -in saml_key.pem -pubout > saml.pub

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java BasicDataSource提交不起作用   java如何在SpringSecurity中为特殊情况下的身份验证失败定制http状态代码?   java Hibernate,SQL Server 2016=SQL错误:207无效列名   继承确保运行时Java超类是正确的   java重写hashcode方法以返回类中变量的hashcode   java无法缩放不同设备的文本大小   java Comparator作为静态字段接口还是实现?   java MessageSource不重新加载属性文件   使用方法setToolTip()在中更改后,操作上的java Keybinding工具提示消失   java使用maven添加调试符号   java转换时应该绑定哪个版本的JRE。使用launch4j将jar转换为exe   java Anylogic实验坚持使用范围内的可变参数,但在自由形式参数中工作良好   关于BuffereImage和Image的java问题   java当我试图在终端的Applications文件夹中显示内容时,我得到了“chromeapps.localized”   java如何使用正则表达式模式拆分字符串   java如何计算重复联系人数   java真的不可能保护Android应用免受逆向工程的影响吗?   java无法将值从活动转移到存储库以将其传递到Dao方法   Java中的名称空间包相对标识符路径   排序Java添加和排序列表的快速方法