kerberos高级接口
kerberos的Python项目详细描述
pykerberos包
这个python包是kerberos(gssapi)的高级包装器 操作。目标是避免构建一个封装 整个kerberos.framework提供了 执行客户机/服务器kerberos所需操作的函数 基于<;http://www.ietf.org/rfc/rfc4559.txt>;的身份验证。
这里的大部分C代码都改编自Apache的mod_auth_kerb-5.0rc7。
构建
在此目录中,运行:
python setup.py build
测试
若要在“测试”文件夹中运行测试,必须在 测试机器。你可以使用script.travis.sh快速简单的方法 设置可用于测试的kerberos kdc和apache web端点。 否则,您还可以运行以下命令来运行自包含的docker 容器
Docker命令需要与这个库在同一个目录下运行,并且 您可以通过更改 命令中设置的pyenv环境值。
有关详细信息,请查看testing_notes.md。
重要
此库提供的checkpassword方法仅用于测试目的 不提供任何针对可能的kdc欺骗的保护。这种方法不应该用在任何 生产代码。
通道绑定
您可以使用此库通过通道绑定支持进行身份验证。渠道 绑定是标识与 身份验证。可以使用通道绑定提供有效的 身份。一些服务,如微软的扩展保护可以强制 授权时的通道绑定支持,您可以使用此库来满足 这些要求。
有关通过gssapi设置的通道绑定的更多详细信息,请参见此处 <;https://docs.oracle.com/cd/E19455-01/806-3814/overview-52/index.html>;。使用 以TLS为例,这是如何将通道绑定支持添加到 认证机制。以下代码片段基于RFC5929 <;https://tools.ietf.org/html/rfc5929>;使用“TLS服务器终结点” 键入。
importhashlibdefget_channel_bindings_application_data(socket):# This is a highly simplified example, there are other use cases# where you might need to use different hash types or get a socket# object somehow.server_certificate=socket.getpeercert(True)certificate_hash=hashlib.sha256(server_certificate).hexdigest().upper()certificate_digest=base64.b16decode(certificate_hash)application_data=b'tls-server-end-point:%s'%certificate_digestreturnapplication_datadefmain():# Code to setup a socket with the server# A lot of code to setup the handshake and start the auth processsocket=getsocketsomehow()# Connect to the host and start the auth process# Build the channel bindings objectapplication_data=get_channel_bindings_application_data(socket)channel_bindings=kerberos.channelBindings(application_data=application_data)# More work to get responses from the serverresult,context=kerberos.authGSSClientInit(kerb_spn,gssflags=gssflags,principal=principal)# Pass through the channel_bindings object as created in the kerberos.channelBindings methodresult=kerberos.authGSSClientStep(context,neg_resp_value,channel_bindings=channel_bindings)# Repeat as necessary
python api
请参见kerberos.py。
版权和许可
版权所有(c)2006-2018 Apple Inc.保留所有权利。
此软件是在apache许可2.0版下授权的。这个 apache许可证是一个成熟的开源许可证,支持 协同开源软件开发。
有关许可条款的全文,请参阅“许可证”文件。