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