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

* Commit of work of config attributes

parent 905a755d
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,7 @@ our (@ISA,@EXPORT); ...@@ -32,6 +32,7 @@ our (@ISA,@EXPORT);
addAttribute addAttribute
checkAttributeAuth checkAttributeAuth
getReplyAttribute getReplyAttribute
checkAttributeConfig
); );
...@@ -408,6 +409,80 @@ sub getReplyAttribute ...@@ -408,6 +409,80 @@ sub getReplyAttribute
## @fn checkAttributeConfig($server,$packetAttributes,$attribute)
# Function to check an attribute in the configuration stage
#
# @param server Server instance
# @param packetAttributes Hashref of attributes provided, eg. Those from the packet
# @param attribute Attribute to check, eg. One of the ones from the database
sub checkAttributeConfig
{
my ($server,$configAttributes,$attribute) = @_;
# Matched & ok?
my $matched = 0;
# Figure out our attr values
my @attrValues;
if (ref($attribute->{'Value'}) eq "ARRAY") {
@attrValues = @{$attribute->{'Value'}};
} else {
@attrValues = ( $attribute->{'Value'} );
}
$server->log(LOG_DEBUG,"[ATTRIBUTES] Processing CONFIG attribute value ".niceUndef($attrVal)." against: '".
$attribute->{'Name'}."' ".$attribute->{'Operator'}." '".join("','",@attrValues)."'");
# Loop with all the test attribute values
foreach my $tattrVal (@attrValues) {
# FIXME
# Operator: +=
#
# Use: Attribute += Value
# Always matches as a check item, and adds the current
# attribute with value to the list of configuration items.
#
# As a reply item, it has an itendtical meaning, but the
# attribute is added to the reply items.
if ($attribute->{'Operator'} eq '+=') {
$server->log(LOG_DEBUG,"[ATTRIBUTES] Operator '+=' triggered: Adding item to configuration items.");
$matched = 1;
# FIXME
# Operator: :=
#
# Use: Attribute := Value
# Always matches as a check item, and replaces in the configuration items any attribute of the same name.
# If no attribute of that name appears in the request, then this attribute is added.
#
# As a reply item, it has an itendtical meaning, but for the reply items, instead of the request items.
} elsif ($attribute->{'Operator'} eq ':=') {
$server->log(LOG_DEBUG,"[ATTRIBUTES] Operator ':=' triggered: Adding or replacing item in configuration items.");
$matched = 1;
# Attributes that are not defined
} else {
# Ignore
$matched = 2;
last;
}
}
# Some debugging info
if ($matched == 1) {
$server->log(LOG_DEBUG,"[ATTRIBUTES] - Attribute '".$attribute->{'Name'}."' matched");
} elsif ($matched == 2) {
$server->log(LOG_DEBUG,"[ATTRIBUTES] - Attribute '".$attribute->{'Name'}."' ignored");
} else {
$server->log(LOG_DEBUG,"[ATTRIBUTES] - Attribute '".$attribute->{'Name'}."' not matched");
}
return $matched;
}
......
...@@ -30,7 +30,6 @@ use smradius::util; ...@@ -30,7 +30,6 @@ use smradius::util;
use DateTime; use DateTime;
use POSIX qw(ceil); use POSIX qw(ceil);
use Data::Dumper;
# Exporter stuff # Exporter stuff
require Exporter; require Exporter;
......
...@@ -71,8 +71,6 @@ sub init ...@@ -71,8 +71,6 @@ sub init
Name, Operator, Value Name, Operator, Value
FROM FROM
@TP@realm_attributes @TP@realm_attributes
WHERE
RealmID = %{realms.ID}
'; ';
......
...@@ -547,8 +547,6 @@ sub process_request { ...@@ -547,8 +547,6 @@ sub process_request {
# Main user hash with everything in # Main user hash with everything in
my $user; my $user;
# #
# GRAB CONFIG FIXME # GRAB CONFIG FIXME
# #
...@@ -563,13 +561,35 @@ sub process_request { ...@@ -563,13 +561,35 @@ sub process_request {
if ($configData) { if ($configData) {
# Add what we have received to the user hash # Add what we have received to the user hash
$user->{'ConfigData'} = $configData; $user->{'ConfigData'} = $configData;
$self->log(LOG_NOTICE,"[SMRADIUS] ConfigData: ".Dumper($user->{'ConfigData'}));
last; last;
} }
} }
} }
#
# FIXME USER
#
# Build a list of our attributes in the packet
my $configAttributes;
foreach my $attr ($pkt->attributes) {
$configAttributes->{$attr} = $pkt->rawattr($attr);
}
# Loop with attributes we got from the user
foreach my $attribute (@{$user->{'ConfigData'}->{'ConfigAttributes'}}) {
# Check attribute against authorization attributes
my $res = checkAttributeConfig($self,$configAttributes,$attribute);
if ($res == 0) {
$self->log(LOG_DEBUG,"[SMRADIUS] Failed checkAttributeConfig(): Do something here");
last;
}
}
# We don't want to process everyting if something doesn't match
# last if (!$authorized);
#}
# UserDB module if we using/need it # UserDB module if we using/need it
my $userdb; my $userdb;
......
...@@ -103,15 +103,13 @@ mod_auth_mschap ...@@ -103,15 +103,13 @@ mod_auth_mschap
EOT EOT
users=<<EOT users=<<EOT
mod_userdb_test
mod_userdb_sql mod_userdb_sql
EOT EOT
[system] [system]
plugins=<<EOT plugins=<<EOT
mod_config_test mod_userdb_sql
mod_config_sql
EOT EOT
...@@ -124,7 +122,7 @@ EOT ...@@ -124,7 +122,7 @@ EOT
[accounting] [accounting]
plugins=<<EOT plugins=<<EOT
mod_accounting_test mod_accounting_sql
EOT EOT
......
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