0ab4f1456b5ea3d9ce4360b2c58fa90c7f987354
[freeside.git] / fs_selfservice / FS-SelfService / SelfService / FreeRadiusVoip.pm
1 # Add this to the modules section of radiusd.conf
2 #  #path to this module
3 #  module=/usr/local/share/perl/5.8.8/FS/SelfService/FreeRadiusVoip.pm
4 #  func_autheenticate = authenticate
5 #
6 #In the Authorize section 
7 #Make sure that you have 'files' uncommented. Then add a line containing 'perl'
8 # after it. 
9 #
10 #In the Authentication section add 
11 # Auth-Type Perl { 
12 #   perl 
13 # } 
14 #
15 # #N/A# Add a line containing 'perl' to the Accounting section. 
16
17 # In the users file comment the 'DEFAULT Auth-Type = System' lines 
18 # and then add 
19 #  DEFAULT Auth-Type = Perl 
20 #  Fall-Through = 1 
21
22 BEGIN { $FS::SelfService::skip_uid_check = 1; } 
23
24 use strict;
25 use vars qw(%RAD_REQUEST %RAD_REPLY %RAD_CHECK);
26 #use Data::Dumper;
27 use FS::SelfService qw(call_time);
28
29 use constant RLM_MODULE_REJECT=>   0; #immediately reject the request
30 use constant RLM_MODULE_FAIL=>     1; #module failed, don't reply
31 use constant RLM_MODULE_OK=>       2; #the module is OK, continue
32 use constant RLM_MODULE_HANDLED=>  3; #the module handled the request, so stop
33 use constant RLM_MODULE_INVALID=>  4; #the module considers the request invalid
34 use constant RLM_MODULE_USERLOCK=> 5; #reject the request (user is locked out)
35 use constant RLM_MODULE_NOTFOUND=> 6; #user not found
36 use constant RLM_MODULE_NOOP=>     7; #module succeeded without doing anything
37 use constant RLM_MODULE_UPDATED=>  8; #OK (pairs modified)
38 use constant RLM_MODULE_NUMCODES=> 9; #How many return codes there are
39
40 sub authenticate {
41
42   #my $src = $RAD_REQUEST{'User-Name'};
43
44 #  my $response = call_time( 'src' => $RAD_REQUEST{'Calling-Station-Id'},
45 #                            'dst' => $RAD_REQUEST{'Called-Station-Id'},  );
46 #
47 #  if $response{$
48
49   $RAD_REPLY{'Session-Timeout'} = 420;
50   return RLM_MODULE_UPDATED;
51
52 }
53
54 sub log_request_attributes {
55        # This shouldn't be done in production environments!
56        # This is only meant for debugging!
57        for (keys %RAD_REQUEST) {
58                &radiusd::radlog(1, "RAD_REQUEST: $_ = $RAD_REQUEST{$_}");
59        }
60 }
61