RADIUS authentication module
Project description
py-radius
RADIUS authentication module for Python 2.7.13+
(c) 1999 Stuart Bishop <stuart@stuartbishop.net>
This module provides basic RADIUS client capabilities, allowing your Python code to authenticate against any RFC2138 compliant RADIUS server.
Installation
$ pip install py-radius
Usage
The radius.py module can be run from the command line, providing a minimal RADIUS client to test out RADIUS servers:
$ 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
Example
Here is an example of using the library.
import radius
radius.authenticate(secret, username, password, host='radius', port=1812)
# - OR -
r = radius.Radius(secret, host='radius', port=1812)
print('success' if r.authenticate(username, password) else 'failure')
If your RADIUS server requires challenge/response, the usage is a bit more complex.
import radius
r = radius.Radius(secret, host='radius')
try:
print('success' if r.authenticate(username, password) else 'failure')
sys.exit(0)
except radius.ChallengeResponse as e:
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} if e.state else {}
# Finally authenticate again using the challenge response from the user
# in place of the password.
print('success' if r.authenticate(username, response, attributes=attrs)
else 'failure')
This module has extensive logging, enable it using the Python logging framework.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
radius-0.0.3.tar.gz
(9.1 kB
view hashes)
Built Distribution
Close
Hashes for radius-0.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 849aae09df941a012be930535e346e57ba105ed046bf2f2f90bf8ed31ba63e50 |
|
MD5 | 991e6ad842de1e7230902069c1faa508 |
|
BLAKE2b-256 | a588591649a726aabb0f0a75db71fec29c34dad540eea1f0089b2874d34d13a1 |