Skip to content

Commit

Permalink
Merge a771db7 into a543931
Browse files Browse the repository at this point in the history
  • Loading branch information
btimby committed May 16, 2017
2 parents a543931 + a771db7 commit ed2f0f0
Show file tree
Hide file tree
Showing 8 changed files with 833 additions and 276 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
ignore = F821
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: python
python:
- '2.7.13'
install:
- make dependencies
script:
- make travis
after_success:
- make coveralls
deploy:
provider: pypi
user: "Ben.Timby"
password:
secure: "CwfEq0SYcw1CpNrdjMFD/R8rCZVWwTeDZQZj6Z4LIi2PUd++BdDcB9S/NVCjChxD4C9CrausH/iFoPnBYFyNf5c13BTxuo5oFC7PUY99a/PjHR8vjGC48lj5KGE4W5O2qQQkgKojcP6rD8e1YPmaO9miRKIT9DLRpIqnSW4p+jI="
on:
tags: true
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include README.rst
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
test:
coverage run tests.py

lint:
flake8 radius.py

dependencies:
pip install coverage coveralls flake8

travis: lint test

coveralls:
coveralls -v
121 changes: 0 additions & 121 deletions README.md

This file was deleted.

88 changes: 88 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
.. image:: https://travis-ci.org/btimby/py-radius.svg?branch=master
:alt: Travis CI Status
:target: https://travis-ci.org/btimby/py-radius

.. image:: https://coveralls.io/repos/github/btimby/py-radius/badge.svg?branch=master
:target: https://coveralls.io/github/btimby/py-radius?branch=master
:alt: Code Coverage

.. image:: https://badge.fury.io/py/py-radius.svg
:target: https://badge.fury.io/py/py-radius

py-radius
=========

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.

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.

.. code:: python
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.

.. code:: python
import radius
r = radius.Radius(secret, host='radius')
try:
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.
# By default send no attributes.
attrs = radius.Attributes()
if e.state:
# If server provided state, echo it.
attrs['State'] = e.state
# Finally authenticate again using the challenge response from the user
# in place of the password.
r.authenticate(username, response, attributes=attrs)
This module has extensive logging, enable it using the Python logging framework.

0 comments on commit ed2f0f0

Please sign in to comment.