Skip to main content

RADIUS Server

Project description

Tests python pre-commit Code style: ruff Checked with mypy

pyrad2 is an implementation of a RADIUS client/server as described in RFC2865 and of RADSEC client/server as described in RFC6614. It takes care of all the details like building RADIUS packets,sending them and decoding responses.

Documentation can be found here.

Introduction

pyrad2 is an implementation of a RADIUS client/server as described in RFC2865. It takes care of all the details like building RADIUS packets, sending them and decoding responses.

What this fork does differently from upstream pyrad:

  • Adds RadSec (RFC 6614) client and server (experimental)
  • Adds Status-Server (RFC 5997) health checks across sync, async, and RadSec
  • Adds RFC 5080 §2.2.2 duplicate detection / response cache — retransmitted Access/Accounting/CoA/Disconnect-Requests replay the cached reply bytes instead of re-running the handler, which is what keeps EAP State continuity intact and stops accounting double-counts
  • Adds Message-Authenticator enforcement (validated whenever present, required for EAP, opt-in to require on every packet)
  • Adds CoA/Disconnect (RFC 5176) handling with default NAK behavior + Error-Cause so unhandled requests are answered cleanly
  • Loads FreeRADIUS dictionaries with broad fidelity: ifid (RFC 3162) and ether (RFC 6911) types, the concat attribute option (RFC 7268), the per-vendor format= directive (1/2/4-byte type fields, 0/1/2-byte length fields), RFC 6929 extended / long-extended attributes (types 241–246) with transparent fragmentation, and EVS (Extended-Vendor-Specific) via BEGIN-VENDOR parent= syntax
  • Adds a PYRAD2_TRACE=1 wire-level packet dump for every request_packet / reply_packet / decode_packet
  • Adds scenarios/ — single-process end-to-end demos that show a full RADIUS exchange on one log
  • Drops Python <3.12 and the twisted integration; converts the entire codebase to snake_case (see Pyrad Compatibility)
  • Extensive typing (mypy-clean) and significantly higher test coverage
  • Numerous async-client bug fixes (retry/timeout correctness, EAP-MD5 parity with the sync client)

Note that this is not a stand-alone Radius implementation like FreeRadius. You are supposed to inherit the server classes and code your own behind-the-scenes implementation. This package allows you to code your business logic on top of it.

Requirements & Installation

pyrad2 requires Python 3.12 and uses uv. On a Mac, you can simply run brew install uv.

Examples and scenarios

See the Getting Started guide for a better overview.

The repo ships two complementary surfaces depending on what you want:

  • examples/ — operational scripts to copy into your project and edit. Server runs in one terminal, client in another. Targets: make server, make auth, make server_radsec, make server_coa, make acct, etc.
  • scenarios/ — single-process end-to-end demos that run a server and client in one event loop. Not meant to be edited — they're runnable explanations of what a RADIUS flow looks like, top to bottom, on one log. This is the fastest way to learn what pyrad2 actually does.
make scenario_auth     # Access-Request → Access-Accept (UDP, RFC 2865)
make scenario_acct     # Accounting-Request → Accounting-Response
make scenario_coa      # CoA-Request → CoA-ACK (RFC 5176)
make scenario_status   # Status-Server health check (RFC 5997)
make scenario_dedup    # Duplicate detection / response cache (RFC 5080)
make scenario_radsec   # RadSec (RFC 6614) — mutual TLS, Access-Request
make demo              # all six sequentially

Set PYRAD2_TRACE=1 on any script — scenario, example, or your own code — to dump every packet's wire bytes and decoded AVPs as they cross request_packet / reply_packet / decode_packet. Pair it with a scenario for a "watch a full RADIUS exchange one byte at a time" view:

PYRAD2_TRACE=1 make scenario_auth

Tests

Run make test.

Author, Copyright, Availability

pyrad2 is currently maintaned by Nicholas Amorim <<nicholas@santos.ee>.

pyrad was written by Wichert Akkerman <wichert@wiggy.net> and is maintained by Christian Giese (GIC-de) and Istvan Ruzman (Istvan91).

This project is licensed under a BSD license.

Copyright and license information can be found in the LICENSE.txt file.

The current version and documentation can be found on pypi: https://pypi.org/project/pyrad2/

Bugs and wishes can be submitted in the pyrad issue tracker on github: https://github.com/nicholasamorim/pyrad2/issues

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrad2-2.3.tar.gz (88.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrad2-2.3-py3-none-any.whl (62.7 kB view details)

Uploaded Python 3

File details

Details for the file pyrad2-2.3.tar.gz.

File metadata

  • Download URL: pyrad2-2.3.tar.gz
  • Upload date:
  • Size: 88.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for pyrad2-2.3.tar.gz
Algorithm Hash digest
SHA256 2b64708bec8a455281a8b277bb069cec4485fb6b5e0a6f35f75f0c14dc2fde20
MD5 3cd946e9e67ff2c732d8cba1d940d4d4
BLAKE2b-256 6aed5173470dae4457c0ac9e53f602a6ec6626cd6b4bf94f32a3421d343ae468

See more details on using hashes here.

File details

Details for the file pyrad2-2.3-py3-none-any.whl.

File metadata

  • Download URL: pyrad2-2.3-py3-none-any.whl
  • Upload date:
  • Size: 62.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for pyrad2-2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3560c83541cf4b9e656387b4727730379664a1ca95f710c0b3ba4bbf4d2d0798
MD5 0d9deff30afa295fee06a7f879306811
BLAKE2b-256 2e9e9ac82727ef89b14088d3ed5315c848247b4acfa5b743244c931697f21dad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page