misc_radius_admin.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <?xml version="1.0" encoding='ISO-8859-1'?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  4. <!-- Include general documentation entities -->
  5. <!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <!-- misc_radius Module User's Guide -->
  9. <chapter>
  10. <title>&adminguide;</title>
  11. <section>
  12. <title>Overview</title>
  13. <para>
  14. The <emphasis>misc_radius</emphasis> module implements various
  15. RADIUS related functions.
  16. Functions exist for loading caller's or callee's
  17. attributes into AVPs, checking if user belongs to a group, and
  18. checking if a specific URI belongs to a user. It thus replaces old
  19. avp_radius, group_radius, and uri_radius modules.
  20. </para>
  21. <para>
  22. All functions of this module load AVPs from SIP-AVP reply items
  23. received from RADIUS upon a successful request. Value of the
  24. SIP-AVP reply item must be a string of form:
  25. <itemizedlist>
  26. <listitem><para><emphasis>
  27. value = SIP_AVP_NAME SIP_AVP_VALUE
  28. </emphasis></para></listitem>
  29. <listitem><para><emphasis>
  30. SIP_AVP_NAME = STRING_NAME | '#'ID_NUMBER
  31. </emphasis></para></listitem>
  32. <listitem><para><emphasis>
  33. SIP_AVP_VALUE = ':'STRING_VALUE | '#'NUMBER_VALUE
  34. </emphasis></para></listitem>
  35. </itemizedlist>
  36. </para>
  37. <example>
  38. <title><quote>SIP-AVP</quote> RADIUS AVP examples</title>
  39. <programlisting format="linespecific">
  40. ....
  41. "email:[email protected]"
  42. -> STRING NAME AVP (email) with STRING VALUE ([email protected])
  43. "#14:[email protected]"
  44. -> ID AVP (14) with STRING VALUE ([email protected])
  45. "age#28"
  46. -> STRING NAME AVP (age) with INTEGER VALUE (28)
  47. "#14#28"
  48. -> ID AVP (14) with INTEGER VALUE (28)
  49. ....
  50. </programlisting>
  51. </example>
  52. <para>
  53. Unlike in old avp_radius module, functions
  54. radius_load_calle[re]_avps() do not prefix string names of AVPs
  55. by string
  56. <quote>caller_</quote> or <quote>callee_</quote> depending if
  57. caller's or callee's attributes were loaded. If you need these
  58. prefixes, make your RADIUS server to prepend them into attribute
  59. names when it constructs reply items.
  60. </para>
  61. <para>
  62. A new feature of misc_radius module is that it is now possible
  63. to include user defined extra RADIUS attributes in all requests
  64. send by functions of this module.
  65. </para>
  66. </section>
  67. <section>
  68. <title>Dependencies</title>
  69. <section>
  70. <title>&kamailio; Modules</title>
  71. <para>
  72. The module depends on the following modules (in the other words
  73. the listed modules must be loaded before this module):
  74. <itemizedlist>
  75. <listitem>
  76. <para><emphasis>none</emphasis></para>
  77. </listitem>
  78. </itemizedlist>
  79. </para>
  80. </section>
  81. <section>
  82. <title>External Libraries or Applications</title>
  83. <para>
  84. The following libraries or applications must be installed
  85. before running &kamailio; with this module loaded:
  86. </para>
  87. <itemizedlist>
  88. <listitem>
  89. <para><emphasis>radiusclient-ng</emphasis> 0.5.0 or higher,
  90. <emphasis>freeradius-client</emphasis> <ulink
  91. url='https://github.com/FreeRADIUS/freeradius-client/'>
  92. https://github.com/FreeRADIUS/freeradius-client/</ulink> or
  93. <emphasis>radcli</emphasis> <ulink
  94. url='http://radcli.github.io/radcli/'>
  95. http://radcli.github.io/radcli/</ulink>.
  96. </para>
  97. </listitem>
  98. <listitem>
  99. <para>
  100. <emphasis>freeradius-client</emphasis> library can be used after
  101. setting FREERADIUS variable in source code with
  102. <emphasis>'export FREERADIUS=1'</emphasis> before compile.
  103. </para>
  104. </listitem>
  105. <listitem>
  106. <para>
  107. <emphasis>radcli</emphasis> library can be used after
  108. setting RADCLI variable in source code with
  109. <emphasis>'export RADCLI=1'</emphasis> before compile.
  110. </para>
  111. </listitem>
  112. </itemizedlist>
  113. </section>
  114. </section>
  115. <section>
  116. <title>Parameters</title>
  117. <section id="mrad.p.config">
  118. <title><varname>radius_config</varname> (string)</title>
  119. <para>
  120. This is the location of the configuration file of radius client
  121. libraries.
  122. </para>
  123. <para>
  124. Default value is
  125. <quote>/usr/local/etc/radiusclient-ng/radiusclient.conf</quote>.
  126. </para>
  127. <example>
  128. <title><varname>radius_config</varname> parameter usage</title>
  129. <programlisting format="linespecific">
  130. ...
  131. modparam("misc_radius", "radius_config", "/etc/radiusclient.conf")
  132. ...
  133. </programlisting>
  134. </example>
  135. </section>
  136. <section id="mrad.p.caller_srv_type">
  137. <title><varname>caller_service_type</varname> (integer)</title>
  138. <para>
  139. This is the value of the Service-Type radius attribute to be
  140. used, when caller's attributes are loaded.
  141. </para>
  142. <para>
  143. Default value is dictionary value of <quote>SIP-Caller-AVPs</quote>
  144. Service-Type.
  145. </para>
  146. <example>
  147. <title><varname>caller_service_type</varname> parameter usage</title>
  148. <programlisting format="linespecific">
  149. ...
  150. modparam("misc_radius", "caller_service_type", 18)
  151. ...
  152. </programlisting>
  153. </example>
  154. </section>
  155. <section id="mrad.p.callee_srv_type">
  156. <title><varname>callee_service_type</varname> (integer)</title>
  157. <para>
  158. This is the value of the Service-Type radius attribute to be
  159. used, when callee's attributes are loaded.
  160. </para>
  161. <para>
  162. Default value is dictionary value of <quote>SIP-Callee-AVPs</quote>
  163. Service-Type.
  164. </para>
  165. <example>
  166. <title><varname>callee_service_type</varname> parameter usage</title>
  167. <programlisting format="linespecific">
  168. ...
  169. modparam("misc_radius", "callee_service_type", 19)
  170. ...
  171. </programlisting>
  172. </example>
  173. </section>
  174. <section id="mrad.p.group_srv_type">
  175. <title><varname>group_service_type</varname> (integer)</title>
  176. <para>
  177. This is the value of Service-Type RADIUS attribute to be
  178. used, when radius_is_user_in() function is called.
  179. </para>
  180. <para>
  181. Default value is dictionary value of <quote>Group-Check</quote>
  182. Service-Type.
  183. </para>
  184. <example>
  185. <title><varname>group_service_type</varname> parameter usage</title>
  186. <programlisting format="linespecific">
  187. ...
  188. modparam("misc_radius", "group_service_type", 20)
  189. ...
  190. </programlisting>
  191. </example>
  192. </section>
  193. <section id="mrad.p.uri_srv_type">
  194. <title><varname>uri_service_type</varname> (integer)</title>
  195. <para>
  196. This is the value of Service-Type RADIUS attribute to be
  197. used, when radius_does_uri[_user]_exist() function is
  198. called.
  199. </para>
  200. <para>
  201. Default value is dictionary value of <quote>Call-Check</quote>
  202. Service-Type.
  203. </para>
  204. <example>
  205. <title><varname>uri_service_type</varname> parameter usage</title>
  206. <programlisting format="linespecific">
  207. ...
  208. modparam("misc_radius", "uri_service_type", 21)
  209. ...
  210. </programlisting>
  211. </example>
  212. </section>
  213. <section id="mrad.p.caller_extra">
  214. <title><varname>caller_extra</varname> (string)</title>
  215. <para>
  216. Semi-colon separated list of extra RADIUS
  217. attribute name=pseudo variable pairs. When
  218. radius_load_caller_avps() is called, the listed extra
  219. attributes are included RADIUS request with
  220. current values of corresponding pseudo variables.
  221. </para>
  222. <para>
  223. There is no default value, i.e., by default no extra
  224. attributes are included.
  225. </para>
  226. <example>
  227. <title><varname>caller_extra</varname> parameter usage</title>
  228. <programlisting format="linespecific">
  229. ...
  230. modparam("misc_radius", "caller_extra", "Calling-Station-Id=$fu")
  231. ...
  232. </programlisting>
  233. </example>
  234. </section>
  235. <section id="mrad.p.callee_extra">
  236. <title><varname>callee_extra</varname> (string)</title>
  237. <para>
  238. Semi-colon separated list of extra RADIUS
  239. attribute name=pseudo variable pairs. When
  240. radius_load_callee_avps() is called, the listed extra
  241. attributes are included RADIUS request with
  242. current values of corresponding pseudo variables.
  243. </para>
  244. <para>
  245. There is no default value, i.e., by default no extra
  246. attributes are included.
  247. </para>
  248. <example>
  249. <title><varname>callee_extra</varname> parameter usage</title>
  250. <programlisting format="linespecific">
  251. ...
  252. modparam("misc_radius", "callee_extra", "SIP-URI-User=$rU;SIP-URI-Host=$rd")
  253. ...
  254. </programlisting>
  255. </example>
  256. </section>
  257. <section id="mrad.p.group_extra">
  258. <title><varname>group_extra</varname> (string)</title>
  259. <para>
  260. Semi-colon separated list of extra RADIUS
  261. attribute name=pseudo variable pairs. When
  262. radius_is_user_in() is called, the listed extra
  263. attributes are included RADIUS request with
  264. current values of corresponding pseudo variables.
  265. </para>
  266. <para>
  267. There is no default value, i.e., by default no extra
  268. attributes are included.
  269. </para>
  270. <example>
  271. <title><varname>group_extra</varname> parameter usage</title>
  272. <programlisting format="linespecific">
  273. ...
  274. modparam("misc_radius", "group_extra", "My-Special=$avp(i:100)")
  275. ...
  276. </programlisting>
  277. </example>
  278. </section>
  279. <section id="mrad.p.uri_extra">
  280. <title><varname>uri_extra</varname> (string)</title>
  281. <para>
  282. Semi-colon separated list of extra RADIUS
  283. attribute name=pseudo variable pairs. When
  284. radius_does_uri[_user]_exist() function is called, the
  285. listed extra
  286. attributes are included in RADIUS request with
  287. current values of corresponding pseudo variables.
  288. </para>
  289. <para>
  290. There is no default value, i.e., by default no extra
  291. attributes are included.
  292. </para>
  293. <example>
  294. <title><varname>uri_extra</varname> parameter usage</title>
  295. <programlisting format="linespecific">
  296. ...
  297. modparam("misc_radius", "uri_extra", "Called-Station-Id=$tu")
  298. ...
  299. </programlisting>
  300. </example>
  301. </section>
  302. <section id="mrad.p.use_sip_uri_host">
  303. <title><varname>use_sip_uri_host</varname> (integer)</title>
  304. <para>
  305. If zero, radius_does_uri_exist() function sends to
  306. RADIUS server userpart@hostpart in UserName attribute. If
  307. non-zero, radius_does_uri_exist() function sends to
  308. RADIUS server userpart in UserName attribute and hostpart in
  309. SIP-URI-Host attribute.
  310. </para>
  311. <para>
  312. Default value is 0 (only use UserName attribute).
  313. </para>
  314. <example>
  315. <title><varname>use_sip_uri_host</varname> parameter usage</title>
  316. <programlisting format="linespecific">
  317. ...
  318. modparam("misc_radius", "use_sip_uri_host", 1)
  319. ...
  320. </programlisting>
  321. </example>
  322. </section>
  323. <section id="mrad.p.common_response">
  324. <title><varname>common_response</varname> (integer)</title>
  325. <para>
  326. Set it to 1 if you need common radius response attributes to
  327. be added as AVPs in <function moreinfo="none">radius_load_caller_avps</function>
  328. and <function moreinfo="none">radius_load_callee_avps</function>
  329. with name as radius attribute name and value as radius attribute value.
  330. </para>
  331. <para>
  332. Default value is <quote>0</quote>.
  333. </para>
  334. <example>
  335. <title><varname>common_response</varname> parameter usage</title>
  336. <programlisting format="linespecific">
  337. ...
  338. modparam("misc_radius", "common_response", 1)
  339. ...
  340. radius_load_caller_avps($fU);
  341. ...
  342. </programlisting>
  343. </example>
  344. <example>
  345. <title>radius response with <varname>common_response</varname> value 1</title>
  346. <programlisting format="linespecific">
  347. ...
  348. Sending Access-Accept of id 60 to 192.168.25.32 port 59736
  349. Session-Timeout = 4261674
  350. next-hop-ip = "SIP/00111222333444@cisco-out"
  351. SIP-AVP = "email:[email protected] session-timeout#161 next-hop-ip:h323/[email protected]"
  352. session-protocol = "SIP"
  353. ...
  354. $avp(Session-Timeout) has integer value 4261674
  355. $avp(next-hop-ip) has string value "SIP/005555777888@cisco-out"
  356. $avp(session-protocol) has string value "SIP"
  357. $avp(SIP-AVP) has string value "email:[email protected] session-timeout#161 next-hop-ip:h323/[email protected]"
  358. ...
  359. When receiving negative response, check appropriate avp's:
  360. $avp(Reply-Message) = "Not enough money on deposit '-89.83'. Rejected"
  361. $avp(Filter-Id) = "neg_deposit"
  362. ...
  363. </programlisting>
  364. </example>
  365. </section>
  366. </section>
  367. <section>
  368. <title>Functions</title>
  369. <section id="mrad.f.load_caller_avps">
  370. <title><function
  371. moreinfo="none">radius_load_caller_avps(caller)</function></title>
  372. <para>
  373. The functions loads caller's attributes from radius and
  374. stores them into AVPs. Parameter <quote>caller</quote>
  375. is a string that may contain pseudo variables.
  376. It indicates the user, whose attributes are loaded.
  377. </para>
  378. <para>
  379. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
  380. </para>
  381. <example>
  382. <title><function moreinfo="none">radius_load_caller_avps()</function> usage</title>
  383. <programlisting format="linespecific">
  384. ...
  385. radius_load_caller_avps("$fU@$fd"); # take caller from From URI
  386. ...
  387. radius_load_caller_avps("$au@$ar"); # take caller from Authorization
  388. ... # or Proxy-Authorization header
  389. </programlisting>
  390. </example>
  391. </section>
  392. <section id="mrad.f.load_callee_avps">
  393. <title><function
  394. moreinfo="none">radius_load_callee_avps(callee)</function></title>
  395. <para>
  396. The functions loads callee's attributes from radius and
  397. stores them into AVPs. Parameter <quote>callee</quote>
  398. is a string that may contain pseudo variables.
  399. It indicates the user, whose attributes are loaded.
  400. </para>
  401. <para>
  402. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
  403. </para>
  404. <example>
  405. <title><function moreinfo="none">radius_load_callee_avps()</function> usage</title>
  406. <programlisting format="linespecific">
  407. ...
  408. radius_load_callee_avps("$rU@$rd"); # take callee from Request-URI
  409. ...
  410. </programlisting>
  411. </example>
  412. </section>
  413. <section id="mrad.f.is_user_in">
  414. <title><function
  415. moreinfo="none">radius_is_user_in(user, group)</function></title>
  416. <para>
  417. The functions checks from RADIUS, if user given in first
  418. argument belongs to group given in second argument. Both
  419. arguments are strings, but user string may also contain
  420. pseudo variables. In case of positive result, loads
  421. AVPs from SIP-AVP reply items, if any.
  422. </para>
  423. <para>
  424. This function can be used from REQUEST_ROUTE,
  425. FAILURE_ROUTE, BRANCH_ROUTE, and LOCAL_ROUTE.
  426. </para>
  427. <example>
  428. <title><function moreinfo="none">radius_is_user_in()</function> usage</title>
  429. <programlisting format="linespecific">
  430. ...
  431. radius_is_user_in("$rU@$rd", "1"); # take user from Request-URI
  432. ...
  433. radius_is_user_in("$au@$ar", "group_x");# take user from credentials
  434. ...
  435. </programlisting>
  436. </example>
  437. </section>
  438. <section id="mrad.f.does_uri_exist">
  439. <title><function
  440. moreinfo="none">radius_does_uri_exist([uri])</function></title>
  441. <para>
  442. Checks from RADIUS if userpart@hostpart of Request-URI
  443. or of an URI stored in optional pseudo variable argument
  444. belongs to a local
  445. user. In case of positive result, loads AVPs from
  446. SIP-AVP reply items, if any.
  447. </para>
  448. <para>
  449. This function can be used from REQUEST_ROUTE and
  450. LOCAL_ROUTE.
  451. </para>
  452. <example>
  453. <title><function moreinfo="none">radius_does_uri_exist()</function> usage</title>
  454. <programlisting format="linespecific">
  455. ...
  456. if (radius_does_uri_exist()) ... # check Request-URI
  457. ...
  458. if (radius_does_uri_exist("$avp(i:99)")) ... # check URI in $avp(i:99)
  459. ...
  460. </programlisting>
  461. </example>
  462. </section>
  463. <section id="mrad.f.does_uri_user_exist">
  464. <title><function
  465. moreinfo="none">radius_does_uri_user_exist([user])</function></title>
  466. <para>
  467. Similar to radius_does_uri_exist, but check is done
  468. based only on Request-URI userpart or userpart stored in
  469. optional pseudo variable argument. Userpart should thus
  470. be unique among all user URIs, such as an E.164 number.
  471. In case of positive result, loads AVPs from
  472. SIP-AVP reply items, if any.
  473. </para>
  474. <para>
  475. This function can be used from REQUEST_ROUTE and
  476. LOCAL_ROUTE.
  477. </para>
  478. <example>
  479. <title><function moreinfo="none">radius_does_uri_user_exist()</function> usage</title>
  480. <programlisting format="linespecific">
  481. ...
  482. if (radius_does_uri_user_exist()) ... # check Request-URI userpart
  483. ...
  484. if (radius_does_uri_exist("$fU")) ... # check From URI userpart
  485. ...
  486. </programlisting>
  487. </example>
  488. </section>
  489. </section>
  490. </chapter>