Code Monkey home page Code Monkey logo

radius-rs's Introduction

radius-rs Check crates.io

An async/await native implementation of the RADIUS server and client for Rust. And this also can be used for parsing/constructing (i.e. decoding/encoding) purposes as a RADIUS library.

Description

This RADIUS server and client implementation use tokio to support asynchronous operations natively. This implementation satisfies basic functions that are described in RFC2865.

Usage

Simple example implementations are here:

Those examples implement a quite simple Access-Request processor. You can try those with the following commands.

$ RUST_LOG=debug cargo run --example server
$ RUST_LOG=debug cargo run --example client # in another shell

Supported Dictionaries

This supports the following RFC dictionaries at the moment:

Cryptography method feature option

By default, this library uses MD5 for authentication. Starting from version v0.4.0, it also supports OpenSSL.

If you prefer to use OpenSSL, please add the following lines to your Cargo.toml:

[dependencies]
radius = { version = "__version__", default-features = false, features = ["openssl"] }

Implementation guide for your RADIUS application

Common

  • Packet struct represents request packet and response one.
    • This struct has a list of AVPs.
    • You can get a specific AVP by RFC dictionary module.
      • e.g. rfc2865::lookup_user_name(packet)
        • This method returns Some(Result<String, AVPError>) if the packet contains User-Name attribute.
        • On the other hand, if the package doesn't have that attribute, it returns None.
    • You can construct a packet with RFC dictionary module.
      • e.g. rfc2865::add_user_name(&mut packet, "user")
        • This method adds a User-Name AVP to the packet.
    • Please refer to the rustdoc for each RFC dictionary module in detail.

Server

  • Must implement RequestHandler<T, E> interface.
    • This interface method is the core function of the server application what you need.
  • Please refer also to the example implementation: server

Client

  • Please refer also to the example implementation: client

Roadmap

  • Support the following RFC dictionaries:
    • rfc4679
    • rfc5447
    • rfc5580
    • rfc6929
    • rfc6930
    • rfc7268
    • rfc7499
    • rfc7930
    • rfc8045
    • rfc8559

Development guide for this library

How to generate code from dictionary

$ make gen

code-generator sub project has the responsibility to generate the Rust code according to given RFC dictionary files. The dictionary files are in dicts directory.

The format of the dictionary files respect the FreeRADIUS project's ones.

Note

The original implementation and design of this are inspired by layeh/radius.

Author

moznion ([email protected])

radius-rs's People

Contributors

codertao avatar ctrlaltf24 avatar ivanovuri avatar moznion avatar ramaravishankar avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

radius-rs's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

cargo
code-generator/Cargo.toml
  • regex 1
  • getopts 0.2
  • Inflector 0.11
e2e-test/Cargo.toml
  • tokio 1.35.1
  • async-trait 0.1.77
radius/Cargo.toml
  • md5 0.7.0
  • openssl 0.10
  • chrono 0.4
  • rand 0.8.5
  • num_enum 0.7.2
  • thiserror 1.0
  • log 0.4.20
  • tokio 1.35.1
  • async-trait 0.1.77
github-actions
.github/workflows/test.yaml
  • hecrj/setup-rust-action v2
  • actions/checkout v4

  • Check this box to trigger a request for Renovate to run again on this repository

Consider changing license

I am looking for a Radius lib for Rust and found this library and radius-rust.

Did a quick check of the supported features and API and I think I prefer radius-rs but a copyleft license is a no go for my project.

I also think the current license might prevent more contribution to your lib.

What is your view on changing to a more permissive license like MIT or Apache 2.0?

Thank you

Extensible Authentication Protocol support

One of the most common uses of RADIUS these days is for 802.1x authentication - EAP/RADIUS. RFC3748/RFC3579 requires "super-protocol" interaction in that EAP is embedded within RADIUS and the EAP protocol interactions (init/challenge/response/result) occur within the RADIUS packets atop higher OSI layers than ethernet-level EAPOL transactions.
In order to be able to use this code as a proxy between wireless clients and RADIUS services which themselves do not support EAP, support for RFC3579 would be required in the library.
@moznion - any chance you might have the cycles to implement in the near term, or should i try to pollute your otherwise clean code with my garbage hackery to achieve basic functionality?
Thanks for writing this, neat implementation.

Wrong attribute lengths

APVs like Tunnel-Type are added to a packet using the function from_tagged_u32, which does not take into account the appropriate length of the attribute. Something similar happens with Tunnel-Medium-Type.

pub fn add_tunnel_type(packet: &mut Packet, tag: Option<&Tag>, value: TunnelType) {
packet.add(AVP::from_tagged_u32(TUNNEL_TYPE_TYPE, tag, value as u32));
}

As mentioned in RFC2868, the length for Tunnel-Type is always 6, and this mismatch can cause problems with clients that strictly follow this. radtest will show attributes that do not follow these standards as Attr-N instead of decoding it into the appropriate name, so this can be useful when trying to detect these issues.

Why no "Packet::get_attributes"?

There doesn't seem to be a way to retrieve a list of all AVPs from a Packet currently, just get AVPs with a specific AVPType via Packet::lookup and Packet::lookup_all. Is this intentional?

I see Packet's private attributes field is of type core::attributes::Attributes, which has visibility pub(crate) instead of just pub... so it seems like this might be intentional. If it is, could you provide some of the reasoning as to why? A blanket Packet::get_attributes method would be quite helpful for my use-case.

No way to set packet identifier

I'm using the library for radius load testing / pretty much just using the encode/decode functionality.

Right now there's no way to set the identifier of the packet to anything other then the rand value, which is a problem if you're sending multiple packets over the same socket.

Pedantic request to doc/comment attributes file

I seem to have found a "bald spot" in the otherwise well-annotated and commented code: encode() and decode() in attributes.rs seem a bit sparse on why things are done the way that they are, and it does a fair deal of heavy lifting in the code. If you get a chance at some point, would be swell to have the ins and outs of that code clearly explained to us mortals ๐Ÿ˜„

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.