Code Monkey home page Code Monkey logo

py-radius's Introduction

Travis CI Status Code Coverage

py-radius

RADIUS authentication module for Python 2.7.13+

(c) 1999 Stuart Bishop <[email protected]>

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(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')

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.

py-radius's People

Contributors

btimby avatar

Watchers

Matt Wheeler avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.