1Radius(3) User Contributed Perl Documentation Radius(3)
2
3
4
6 Authen::Radius - provide simple Radius client facilities
7
9 use Authen::Radius;
10
11 $r = new Authen::Radius(Host => 'myserver', Secret => 'mysecret');
12 print "auth result=", $r->check_pwd('myname', 'mypwd'), "\n";
13
14 $r = new Authen::Radius(Host => 'myserver', Secret => 'mysecret');
15 Authen::Radius->load_dictionary();
16 $r->add_attributes (
17 { Name => 'User-Name', Value => 'myname' },
18 { Name => 'Password', Value => 'mypwd' },
19 # RFC 2865 http://www.ietf.org/rfc/rfc2865.txt calls this attribute
20 # User-Password. Check your local RADIUS dictionary to find
21 # out which name is used on your system
22 # { Name => 'User-Password', Value => 'mypwd' },
23 { Name => 'h323-return-code', Value => '0' }, # Cisco AV pair
24 { Name => 'Digest-Attributes', Value => { Method => 'REGISTER' } }
25 );
26 $r->send_packet(ACCESS_REQUEST) and $type = $r->recv_packet();
27 print "server response type = $type\n";
28 for $a ($r->get_attributes()) {
29 print "attr: name=$a->{'Name'} value=$a->{'Value'}\n";
30 }
31
33 The "Authen::Radius" module provides a simple class that allows you to
34 send/receive Radius requests/responses to/from a Radius server.
35
37 new ( Host => HOST, Secret => SECRET [, TimeOut => TIMEOUT] [,Service
38 => SERVICE] [, Debug => Bool])
39 Creates & returns a blessed reference to a Radius object, or undef
40 on failure. Error status may be retrieved with
41 "Authen::Radius::get_error" (errorcode) or "Authen::Radius::str‐
42 error" (verbose error string).
43
44 The default "Service" is "radius", the alternative is
45 "radius-acct". If you do not specify port in the "Host" as a
46 "hostname:port", then port specified in your /etc/services will be
47 used. If there is nothing there, and you did not specify port
48 either then default is 1645 for "radius" and 1813 for
49 "radius-acct".
50
51 Optional parameter "Debug" with a Perl "true" value turns on debug‐
52 ging (verbose mode).
53
55 load_dictionary ( [ DICTIONARY ] )
56 Loads the definitions in the specified Radius dictionary file
57 (standard Livingston radiusd format). Tries to load
58 '"/etc/raddb/dictionary"' when no argument is specified, or dies.
59 NOTE: you need to load valid dictionary if you plan to send Radius
60 requests with other attributes than just "User-Name"/"Password".
61
62 check_pwd ( USERNAME, PASSWORD [,NASIPADDRESS] )
63 Checks with the Radius server if the specified "PASSWORD" is valid
64 for user "USERNAME". Unless "NASIPADDRESS" is soecified, 127.0.0.1
65 will be placed in the NAS-IP-Address attribute. This method is
66 actually a wrapper for subsequent calls to "clear_attributes",
67 "add_attributes", "send_packet" and "recv_packet". It returns 1 if
68 the "PASSWORD" is correct, or undef otherwise.
69
70 add_attributes ( { Name => NAME, Value => VALUE [, Type => TYPE] [,
71 Vendor => VENDOR] }, ... )
72 Adds any number of Radius attributes to the current Radius object.
73 Attributes are specified as a list of anon hashes. They may be
74 "Name"d with their dictionary name (provided a dictionary has been
75 loaded first), or with their raw Radius attribute-type values. The
76 "Type" pair should be specified when adding attributes that are not
77 in the dictionary (or when no dictionary was loaded). Values for
78 "TYPE" can be '"string"', '"integer"', '"ipaddr"' or '"avpair"'.
79
80 get_attributes
81 Returns a list of references to anon hashes with the following
82 key/value pairs : { Name => NAME, Code => RAWTYPE, Value => VALUE,
83 RawValue => RAWVALUE, Vendor => VENDOR }. Each hash represents an
84 attribute in the current object. The "Name" and "Value" pairs will
85 contain values as translated by the dictionary (if one was loaded).
86 The "Code" and "RawValue" pairs always contain the raw attribute
87 type & value as received from the server.
88
89 clear_attributes
90 Clears all attributes for the current object.
91
92 send_packet ( REQUEST_TYPE )
93 Packs up a Radius packet based on the current secret & attributes
94 and sends it to the server with a Request type of "REQUEST_TYPE".
95 Exported "REQUEST_TYPE" methods are '"ACCESS_REQUEST"',
96 '"ACCESS_ACCEPT"' , '"ACCESS_REJECT"', '"ACCOUNTING_REQUEST"',
97 '"ACCOUNTING_RESPONSE"', and '"DISCONNECT_REQUEST"'. Returns the
98 number of bytes sent, or undef on failure.
99
100 recv_packet
101 Receives a Radius reply packet. Returns the Radius Reply type (see
102 possible values for "REQUEST_TYPE" in method "send_packet") or
103 undef on failure. Note that failure may be due to a failed recv()
104 or a bad Radius response authenticator. Use "get_error" to find
105 out.
106
107 get_error
108 Returns the last "ERRORCODE" for the current object. Errorcodes are
109 one-word strings always beginning with an '"E"'.
110
111 strerror ( [ ERRORCODE ] )
112 Returns a verbose error string for the last error for the current
113 object, or for the specified "ERRORCODE".
114
116 Carl Declerck <carl@miskatonic.inbe.net> - original design Alexander
117 Kapitanenko <kapitan@portaone.com> and Andrew Zhilenko <andrew@por‐
118 taone.com> - later modifications. Andrew Zhilenko <andrew@por‐
119 taone.com> is a current module's maintaner at CPAN.
120
121
122
123perl v5.8.8 2007-02-20 Radius(3)