Skip to content
Snippets Groups Projects
Commit c7fd53b2 authored by Robert Anderson's avatar Robert Anderson
Browse files

* Fixed up mod_auth_pap a bit

* Added mod_userdb_test for testing of radius server
parent f4fdf102
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,6 @@ require Exporter;
our (@ISA,@EXPORT,@EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT = qw(
encode_chap
);
@EXPORT_OK = qw(
);
......@@ -92,29 +91,15 @@ sub authenticate
print(STDERR "CALC\n");
print(STDERR "Result : len = ".length($clearPassword).", hex = ".unpack("H*",$clearPassword).", password = $clearPassword\n");
return MOD_RES_NACK;
}
# Encode CHAP password from ID, Challenge and Password
sub encode_chap
{
my ($id,$challenge,$password) = @_;
# Compare passwords
if ($user->{'ClearPassword'} eq $clearPassword) {
return MOD_RES_ACK;
}
# Build MD5
my $md5 = Digest::MD5->new();
$md5->add($id);
$md5->add($password);
$md5->add($challenge);
# Create encoded
my $encoded = $id . $md5->digest();
return $encoded;
return MOD_RES_NACK;
}
1;
# Test user database
#
# Copyright (C) 2008, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
package mod_userdb_test;
use strict;
use warnings;
# Modules we need
use smradius::constants;
# Exporter stuff
require Exporter;
our (@ISA,@EXPORT,@EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT = qw(
);
@EXPORT_OK = qw(
);
# Plugin info
our $pluginInfo = {
Name => "Test User Database",
Init => \&init,
# User database
User_find => \&find,
User_get => \&get,
};
## @internal
# Initialize module
sub init
{
my $server = shift;
}
## @find
# Try find a user
#
# @param server Server object
# @param user User
# @param packet Radius packet
#
# @return Result
sub find
{
my ($server,$user,$packet) = @_;
# Test username
if ($user->{'Username'} eq "testuser") {
return MOD_RES_ACK;
}
return MOD_RES_SKIP;
}
## @get
# Try to get a user
#
# @param server Server object
# @param user User
# @param packet Radius packet
#
# @return Result
sub get
{
my ($server,$user,$packet) = @_;
my $userDetails = {
'ClearPassword' => 'doap',
'Attributes' => [
{
'Name' => 'Framed-IP-Address',
'Value' => '192.168.0.233'
},
{
'Name' => 'Session-Timeout',
'Value' => '60'
}
]
};
return $userDetails;
}
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment