Skip to main content

RADIUS Server

Project description

pyrad2

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

A modern Python toolkit for building RADIUS clients and servers.

pyrad2 gives you the protocol - packet encoding, dictionary parsing, transport handling, retransmission, TLS - so you can write the business logic. Build an authentication backend, a CoA proxy, a RadSec accounting collector, or a network-access controller without touching wire formats.

📚 Full documentation: nicholasamorim.github.io/pyrad2

Install

pip install pyrad2     # or: uv add pyrad2

Requires Python 3.12+.

Quick look

from pyrad2.client_async import ClientAsync
from pyrad2.dictionary import Dictionary
from pyrad2.constants import PacketType

client = ClientAsync(server="radius.example.com", secret=b"...", dict=Dictionary("dictionary"))
await client.initialize_transports(enable_auth=True)

req = client.create_auth_packet(User_Name="alice", User_Password="hunter2")
reply = await client.send_packet(req)

if reply.code == PacketType.AccessAccept:
    print("Welcome,", reply["User-Name"][0])

Head to the Getting Started guide for the full walkthrough.

What's in the box

Feature Spec
RADIUS client & server (sync + async) RFC 2865
RadSec - RADIUS over TLS RFC 6614
RADIUS/1.1 over RadSec (experimental) RFC 9765
CoA & Disconnect (Dynamic Authorization) RFC 5176
Status-Server health checks RFC 5997
Duplicate detection / response cache RFC 5080 §2.2.2
FreeRADIUS dictionary support Extended attributes, vendor formats, EVS
Wire-level packet tracing PYRAD2_TRACE=1

pyrad2 is a library, not a daemon. It is not a drop-in replacement for FreeRADIUS; it gives you the moving parts to build your own.

See it run

Two complementary surfaces ship with the repo:

  • scenarios/ - single-process, end-to-end demos. A server and a client run in the same event loop so the full exchange shows up on one log. Don't edit them - they're runnable explanations.
  • examples/ - operational scripts you copy into your project and edit.
make demo                  # all scenarios sequentially

make scenario_auth         # Access-Request → Access-Accept (UDP)
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 (RFC 5080)
make scenario_radsec       # RadSec over mutual TLS (RFC 6614)
make scenario_radsec_v11   # RADIUS/1.1 over RadSec (RFC 9765)

Watch the actual bytes on the wire by setting PYRAD2_TRACE=1 on any script:

PYRAD2_TRACE=1 make scenario_auth

Documentation

Tests

make test

Author, Copyright, Availability

pyrad2 is currently maintained by Nicholas Amorim.

pyrad was written by Wichert Akkerman 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 LICENSE.txt.

Bugs and wishes can be submitted in the pyrad2 issue tracker on GitHub. PRs are very welcome.

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.5.tar.gz (109.5 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.5-py3-none-any.whl (75.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyrad2-2.5.tar.gz
Algorithm Hash digest
SHA256 6ffe4a579d58550da77be7be6b4807e356efb77785e0583cb019f0534de6c454
MD5 740689bbef65b5173822a954fed1b2d6
BLAKE2b-256 4074d42d724eb65f929b4b1b110b649371e05125033e409bdd19d2f883875ef8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyrad2-2.5-py3-none-any.whl
  • Upload date:
  • Size: 75.2 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4c5700ec67ad92af0237fbe6f07f0f856b9a77fccd2016ce90c8f71155e5953e
MD5 5f866e43d5eb5bf0e9ac4ab9482228ee
BLAKE2b-256 fb316dc4ac8254a4fbcea8b8aaaad1e64ae64ed7ede2e6092b617d35467cdb51

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