Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
smradius
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
smradius
smradius
Commits
e366e499
Commit
e366e499
authored
13 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Plain Diff
Merge remote branch 'randerson/validuntil-002' into randerson-nigel-validity-window
parents
1796a7b5
faf660f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smradius/attributes.pm
+2
-1
2 additions, 1 deletion
smradius/attributes.pm
smradius/modules/features/mod_feature_validity.pm
+53
-0
53 additions, 0 deletions
smradius/modules/features/mod_feature_validity.pm
with
55 additions
and
1 deletion
smradius/attributes.pm
+
2
−
1
View file @
e366e499
...
@@ -51,7 +51,8 @@ my @attributeReplyIgnoreList = (
...
@@ -51,7 +51,8 @@ my @attributeReplyIgnoreList = (
'
SMRadius-Capping-Traffic-Limit
',
'
SMRadius-Capping-Traffic-Limit
',
'
SMRadius-Capping-Uptime-Limit
',
'
SMRadius-Capping-Uptime-Limit
',
'
SMRadius-Validity-ValidFrom
',
'
SMRadius-Validity-ValidFrom
',
'
SMRadius-Validity-ValidTo
'
'
SMRadius-Validity-ValidTo
',
'
SMRadius-Validity-ValidWindow
'
);
);
my
@attributeVReplyIgnoreList
=
(
my
@attributeVReplyIgnoreList
=
(
);
);
...
...
This diff is collapsed.
Click to expand it.
smradius/modules/features/mod_feature_validity.pm
+
53
−
0
View file @
e366e499
...
@@ -44,12 +44,14 @@ our $pluginInfo = {
...
@@ -44,12 +44,14 @@ our $pluginInfo = {
# Authentication hook
# Authentication hook
'
Feature_Post-Authentication_hook
'
=>
\
&checkValidity
,
'
Feature_Post-Authentication_hook
'
=>
\
&checkValidity
,
'
Feature_Post-Accounting_hook
'
=>
\
&checkValidity
};
};
# Some constants
# Some constants
my
$VALID_FROM_KEY
=
'
SMRadius-Validity-ValidFrom
';
my
$VALID_FROM_KEY
=
'
SMRadius-Validity-ValidFrom
';
my
$VALID_TO_KEY
=
'
SMRadius-Validity-ValidTo
';
my
$VALID_TO_KEY
=
'
SMRadius-Validity-ValidTo
';
my
$VALID_WINDOW_KEY
=
'
SMRadius-Validity-ValidWindow
';
## @internal
## @internal
...
@@ -154,6 +156,57 @@ sub checkValidity
...
@@ -154,6 +156,57 @@ sub checkValidity
}
}
}
}
# Get validity window
my
$validWindow
;
if
(
defined
(
$user
->
{'
Attributes
'}
->
{
$VALID_WINDOW_KEY
}))
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_VALIDITY] '
"
.
$VALID_WINDOW_KEY
.
"
' is defined
");
# Operator: :=
if
(
defined
(
$user
->
{'
Attributes
'}
->
{
$VALID_WINDOW_KEY
}
->
{'
:=
'}))
{
# Is it a number?
if
(
$user
->
{'
Attributes
'}
->
{
$VALID_WINDOW_KEY
}
->
{'
:=
'}
->
{'
Value
'}
=~
/^\d+$/
)
{
$validWindow
=
$user
->
{'
Attributes
'}
->
{
$VALID_WINDOW_KEY
}
->
{'
:=
'}
->
{'
Value
'};
}
else
{
$server
->
log
(
LOG_NOTICE
,"
[MOD_FEATURE_VALIDITY] '
"
.
$user
->
{'
Attributes
'}
->
{
$VALID_WINDOW_KEY
}
->
{'
:=
'}
->
{'
Value
'}
.
"
' is NOT an integer
");
}
}
else
{
$server
->
log
(
LOG_NOTICE
,"
[MOD_FEATURE_VALIDITY] No valid operators for attribute '
$VALID_WINDOW_KEY
'
");
}
}
# Loop with plugins to find anything supporting getting user data
my
$user_data
;
foreach
my
$module
(
@
{
$server
->
{'
module_list
'}})
{
# Do we have the correct plugin?
if
(
$module
->
{'
Users_data_get
'})
{
$server
->
log
(
LOG_INFO
,"
[MOD_FEATURE_VALIDITY] Found plugin: '
"
.
$module
->
{'
Name
'}
.
"
'
");
# Fetch users data
my
$res
=
$module
->
{'
Users_data_get
'}(
$server
,
$user
,'
global
','
FirstLogin
');
if
(
!
defined
(
$res
))
{
$server
->
log
(
LOG_ERR
,"
[MOD_FEATURE_VALIDITY] No user data found for user '
"
.
$packet
->
attr
('
User-Name
')
.
"
'
");
return
MOD_RES_SKIP
;
}
$user_data
=
$res
;
}
}
# Check if this user should be disconnected
if
(
defined
(
$validWindow
)
&&
defined
(
$user_data
))
{
my
$validUntil
=
$validWindow
+
$user_data
->
{'
Value
'};
if
(
!
defined
(
$validUntil
))
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_VALIDITY] Failed to calculate end of valid window using
"
.
niceUndef
(
$validWindow
)
.
"
and
"
.
niceUndef
(
$user_data
->
{'
Value
'}));
# If current time after start of valid pariod
}
elsif
(
$now
>
$validUntil
)
{
my
$pretty_dt
=
DateTime
->
from_epoch
(
epoch
=>
$validUntil
)
->
strftime
('
%Y-%m-%d %H:%M:%S
');
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_VALIDITY] Current date outside valid window end date: '
"
.
$pretty_dt
.
"
', rejecting
");
# Date not within valid window, must be disconnected
return
MOD_RES_NACK
;
}
}
return
MOD_RES_ACK
;
return
MOD_RES_ACK
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment