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有没有办法使多个对象初始化更紧凑?   java确保BUnit包和测试包不包含在生产代码中   java如何使JTextField更小,而不是填满整个空间?   javaawt的矩形交点   用户连续登录应用程序的java条纹(Android)   maven如何在服务器上运行java项目,并将其作为jar添加到EAR项目中   java如何在jar/war的资源文件夹中创建png?   swing在Java中未选择列表项时禁用按钮   java GridView x BaseAdapter并在onItemClick中重新加载   java Apache POI未应用某些颜色索引   java创建URL使用uri有什么区别。解析/uri。生成器/连接字符串?   java JavaFX jfoenix运行时错误(JFXDatePicker)   右旋转二叉搜索树   在Java标准版中运行Java移动应用程序   java为什么要为每个实例创建静态hashmap?   java如何使用RTC唤醒和报警意图   java获取对象中的JSON表达式   (Java)服务器不接受多个连接   java为什么我的目的地为null?   java使用多个参数执行存储过程,并使用spring数据jpa将结果集映射到非实体类