RADIUS authentication module
Python Makefile
Switch branches/tags
Latest commit 4c36e46 May 19, 2017 @btimby Version bump.
Failed to load latest commit information.
debian Debian packaging structure added Jan 17, 2012
.coveragerc Limit coverage. May 17, 2017
.flake8 Travis. May 16, 2017
.travis.yml 3.3+ required for coverage. May 17, 2017
LICENSE Import from SourceForge/CVS Dec 31, 2011
MANIFEST.in External license file. May 17, 2017
Makefile Coveralls. May 16, 2017
py-radius.spec RPM packaging information, setup.py cleanup. Jan 20, 2012
radius.py Version bump. May 18, 2017
setup.py Py3.3 hates file(). May 17, 2017
tests.py Fix encoding. May 18, 2017


Travis CI Status Code Coverage


RADIUS authentication module for Python 2.7.13+

(c) 1999 Stuart Bishop <zen@shangri-la.dropbear.id.au>

This module provides basic RADIUS client capabilities, allowing your Python code to authenticate against any RFC2138 compliant RADIUS server.


$ pip install py-radius


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


Here is an example of using the library.

import radius

radius.authenticate(username, password, secret, 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')

    print('success' if r.authenticate(username, password) else 'failure')
except radius.ChallengeResponse as e:

# 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.