radius认证模块

radius的Python项目详细描述


Travis CI StatusCode Coveragehttps://badge.fury.io/py/py-radius.svg

py半径

用于python 2.7.13+的radius身份验证模块

(c)1999年斯图尔特毕肖普stuart@stuartbishop.net>;

这个模块提供了基本的radius客户端功能,允许您的python 针对任何符合RFC2138的RADIUS服务器进行身份验证的代码。

安装

$ pip install py-radius

使用量

radius.py模块可以从命令行运行,提供 RADIUS客户端测试RADIUS服务器:

$ python -m radius
Host [default: 'radius']: radius
Port [default: 1812]: 1812
Enter RADIUS Secret: s3cr3t
Enter your username: foobar
Enter your password: qux
...
Authentication Successful

示例

下面是使用库的示例。

importradiusradius.authenticate(secret,username,password,host='radius',port=1812)# - OR -r=radius.Radius(secret,host='radius',port=1812)print('success'ifr.authenticate(username,password)else'failure')

如果您的radius服务器需要质询/响应,那么使用量会更大一些 复杂。

importradiusr=radius.Radius(secret,host='radius')try:print('success'ifr.authenticate(username,password)else'failure')sys.exit(0)exceptradius.ChallengeResponsease:pass# The ChallengeResponse exception has `messages` and `state` attributes# `messages` can be displayed to the user to prompt them for their# challenge response. `state` must be echoed back as a RADIUS attribute.# Send state as an attribute _IF_ provided.attrs={'State':e.state}ife.stateelse{}# Finally authenticate again using the challenge response from the user# in place of the password.print('success'ifr.authenticate(username,response,attributes=attrs)else'failure')

这个模块有大量的日志记录,可以使用python日志框架来实现。

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

推荐PyPI第三方库


热门话题
java OpenShift的齿轮特性   java如何在Liferay站点的每个页面上放置公司地址和电话?   java确定整数数组中是否存在一个子集,在两个条件下求和到给定的目标值   序列化为什么java中的serialVersionUID必须是静态的、最终的、长类型的?   java响应返回null   java注入接口实现Quarkus   java我不明白为什么第二次排序的运行时间比第一次慢?   (Java)显示图像的最佳方式?   java Android应用程序因添加布局而崩溃   java如何在运行时获取泛型变量的类   java Selenium web驱动程序:无效的选择器:*:WebKitFullScreenSentor   Spring中的java注入值始终为空   Eclipse中带有TestNG插件的@BeforeSuite和@AfterSuite的java问题   使用trycatch块、filewriter和printwriter在java中创建自定义类   如何在Java 安卓上绘制相交的两条线