-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
833 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[flake8] | ||
ignore = F821 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include README.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.