Git Product home page Git Product logo

radius.net's Introduction

Overview

Radius.NET is a Radius client built on the .NET 4.5 runtime. It currently only supports the PAP protocol. Other protocols will be added if needed. Pull requests are also welcome.

Requirements

.NET 4.5 installed

Example Usage

var hostname = "UBUNTU-RADIUS";
var sharedKey = "test";
var username = "User1";
var password = "test";

var rc = new RadiusClient(hostname, sharedKey);
var authPacket = rc.Authenticate(username, password);
authPacket.SetAttribute(new VendorSpecificAttribute(10, 1, UTF8Encoding.UTF8.GetBytes("Testing")));
authPacket.SetAttribute(new VendorSpecificAttribute(10, 2, new[] {(byte)7}));
var receivedPacket = rc.SendAndReceivePacket(authPacket).Result;

if (receivedPacket == null) 
	throw new Exception("Can't contact remote radius server !");

switch (receivedPacket.PacketType)
{
	case RadiusCode.ACCESS_ACCEPT:
		Console.WriteLine("Access-Accept");
		foreach (var attr in receivedPacket.Attributes)
			Console.WriteLine(attr.Type.ToString() + " = " + attr.Value);
		break;
	case RadiusCode.ACCESS_CHALLENGE:
		Console.WriteLine("Access-Challenge");
		break;
	case RadiusCode.ACCESS_REJECT:
		Console.WriteLine("Access-Reject");
		if (!rc.VerifyAuthenticator(authPacket, receivedPacket))
			Console.WriteLine("Authenticator check failed: Check your secret");
		break;
	default:
		Console.WriteLine("Rejected");
		break;
}

License

The MIT License (MIT)

Copyright (c)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

radius.net's People

Contributors

aluferyochay avatar cameronism avatar mixja avatar nojan1 avatar scottksmith95 avatar spowser 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

Watchers

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

radius.net's Issues

Add RADIUS code 12

Would you consider adding:
STATUS_SERVER = 12,
as one of the enumerated RADIUS codes
at line 16 of Radius.NET?

Code 12 is shown as "experimental"
in RFC 2865 and gets a full treatment
in RFC 5997.
Your RADIUS client is used by PRTG and a sensor
that made use of a Status-Server code
would make for a very light-weight sensor.

MS-CHAP v2

What would be solution for the use of MS-CHAP v2?

.NET Standard Support

It looks like the project should be .NET Standard 2.0 compatible as-is.
Just update the project format and multi-target for net45 and netstandard20.

Unable to get Result from MVC Web Application

I have created new MVC Web Application and trying to integrate VIP Access Notification but I am not able to receive response from line "RadiusPacket receivedPacket = await rc.SendAndReceivePacket(authPacket);"

Below is my Code in Home Controller.

public ActionResult Index()
{
string[] args = new string[4];
args[0] = "MYIP";
args[1] = "KEY";
args[2] = "UserName";
args[3] = "Password";

        try
        {
            Authenticate(args).Wait();
        }
        catch (Exception e)
        {
            //Console.WriteLine(e);
        }
        return View();
    }

Below is my Authenticate function
private async static Task Authenticate(string[] args)
{

        RadiusClient rc = new RadiusClient(args[0], args[1], 60000, 1822);
        RadiusPacket authPacket = rc.Authenticate(args[2], args[3]);
        authPacket.SetAttribute(new VendorSpecificAttribute(10135, 1, UTF8Encoding.UTF8.GetBytes("Testing")));
        authPacket.SetAttribute(new VendorSpecificAttribute(10135, 2, new[] { (byte)7 }));
        RadiusPacket receivedPacket = await rc.SendAndReceivePacket(authPacket);
        if (receivedPacket == null) throw new Exception("Can't contact remote radius server !");

        switch (receivedPacket.PacketType)
        {
            case RadiusCode.ACCESS_ACCEPT:
                Console.WriteLine("Access-Accept");
                foreach (var attr in receivedPacket.Attributes)
                    Console.WriteLine(attr.Type.ToString() + " = " + attr.Value);
                break;
            case RadiusCode.ACCESS_CHALLENGE:
                Console.WriteLine("Enter Secret : ");
                string secret = Console.ReadLine();
                args[3] = args[3] + secret;
                RadiusClient rc1 = new RadiusClient(args[0], args[1], 60000, 1822);
                RadiusPacket authPacket1 = rc1.Authenticate(args[2], args[3]);
                authPacket1.SetAttribute(new VendorSpecificAttribute(10135, 1, UTF8Encoding.UTF8.GetBytes("Testing")));
                authPacket1.SetAttribute(new VendorSpecificAttribute(10135, 2, new[] { (byte)7 }));
                RadiusPacket receivedPacket1 = await rc1.SendAndReceivePacket(authPacket1);
                Console.WriteLine(receivedPacket1.PacketType);
                break;
            case RadiusCode.ACCESS_REJECT:
                Console.WriteLine("Access-Reject");
                if (!rc.VerifyAuthenticator(authPacket, receivedPacket))
                    Console.WriteLine("Authenticator check failed: Check your secret");
                break;
            default:
                Console.WriteLine("Rejected");
                break;
        }
    }

I am getting notification in my mobile device but after selecting any of the option (e.g. Approve Or Deny) I am not getting response of selected event.

NOTE: Same thing is working fine in my console application.

Let me know if I missed anything in code.

Changing Password Support

Thanks for building this. Is there a way to use this code to change the radius password? I work with a tool that sets an initial password, but then sets the account into a "user must change password at next use" mode. This translates into a "access-challenge" result. But some applications, such as Cisco Anyconnect VPN, can prompt the user to change the password when they receive this challenge.

Is there a way to do this with your code?

Thanks!

Steve

New parameter

Hi guys,

Maybe not the right site but for the love of God i can't seem to add an additional parameter to be sent to radius. I have done everything semantically and syntactically correct but the server send an error of malformed massage.

Any ideas or examples?

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.