group_admin.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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 "../../../docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <!-- Module User's Guide -->
  9. <chapter>
  10. <title>&adminguide;</title>
  11. <section>
  12. <title>Overview</title>
  13. <para>
  14. This module provides functionality for two different methods of group
  15. membership checking.
  16. </para>
  17. <section>
  18. <title>Strict membership checking</title>
  19. <para>
  20. The module uses a database table that contains a list of users and groups
  21. they belong to. The module provides the possibility to check if a
  22. specific user belongs to a specific group.
  23. </para>
  24. <para>
  25. There is no DB caching support, which means that each check involves a DB query.
  26. </para>
  27. </section>
  28. <section>
  29. <title>Regular Expression based checking</title>
  30. <para>
  31. Another database table contains list of regular expressions and
  32. group IDs. A matching occurs if the user URI match the regular
  33. expression. This type of matching may be used to fetch the
  34. group ID(s) the user belongs to (via RE matching) .
  35. </para>
  36. <para>
  37. Due to performance reasons (regular expression evaluation), DB cache
  38. support is available: the table content is loaded into memory at
  39. startup and all regular expressions are compiled.
  40. </para>
  41. </section>
  42. </section>
  43. <section>
  44. <title>Dependencies</title>
  45. <section>
  46. <title>&kamailio; Modules</title>
  47. <para>
  48. The following modules must be loaded before this module:
  49. <itemizedlist>
  50. <listitem>
  51. <para>
  52. A database module, like db_mysql, db_postgres or db_text
  53. </para>
  54. </listitem>
  55. </itemizedlist>
  56. </para>
  57. </section>
  58. <section>
  59. <title>External Libraries or Applications</title>
  60. <para>
  61. The following libraries or applications must be installed before
  62. running &kamailio; with this module loaded:
  63. <itemizedlist>
  64. <listitem>
  65. <para>
  66. <emphasis>None</emphasis>.
  67. </para>
  68. </listitem>
  69. </itemizedlist>
  70. </para>
  71. </section>
  72. </section>
  73. <section>
  74. <title>Parameters</title>
  75. <section id="group.p.db_url">
  76. <title><varname>db_url</varname> (string)</title>
  77. <para>
  78. &url; of the database table to be used.
  79. </para>
  80. <para>
  81. <emphasis>
  82. Default value is
  83. <quote>&defaultrodb;</quote>.
  84. </emphasis>
  85. </para>
  86. <example>
  87. <title>Set <varname>db_url</varname> parameter</title>
  88. <programlisting format="linespecific">
  89. ...
  90. modparam("group", "db_url", "&exampledb;")
  91. ...
  92. </programlisting>
  93. </example>
  94. </section>
  95. <section id="group.p.table">
  96. <title><varname>table</varname> (string)</title>
  97. <para>
  98. Name of the table holding strict definitions of groups and
  99. their members.
  100. </para>
  101. <para>
  102. <emphasis>
  103. Default value is <quote>grp</quote>.
  104. </emphasis>
  105. </para>
  106. <example>
  107. <title>Set <varname>table</varname> parameter</title>
  108. <programlisting format="linespecific">
  109. ...
  110. modparam("group", "table", "grp_table")
  111. ...
  112. </programlisting>
  113. </example>
  114. </section>
  115. <section id="group.p.user_column">
  116. <title><varname>user_column</varname> (string)</title>
  117. <para>
  118. Name of the <quote>table</quote> column holding usernames.
  119. </para>
  120. <para>
  121. <emphasis>
  122. Default value is <quote>username</quote>.
  123. </emphasis>
  124. </para>
  125. <example>
  126. <title>Set <varname>user_column</varname> parameter</title>
  127. <programlisting format="linespecific">
  128. ...
  129. modparam("group", "user_column", "user")
  130. ...
  131. </programlisting>
  132. </example>
  133. </section>
  134. <section id="group.p.domain_column">
  135. <title><varname>domain_column</varname> (string)</title>
  136. <para>
  137. Name of the <quote>table</quote> column holding domains.
  138. </para>
  139. <para>
  140. <emphasis>
  141. Default value is <quote>domain</quote>.
  142. </emphasis>
  143. </para>
  144. <example>
  145. <title>Set <varname>domain_column</varname> parameter</title>
  146. <programlisting format="linespecific">
  147. ...
  148. modparam("group", "domain_column", "realm")
  149. ...
  150. </programlisting>
  151. </example>
  152. </section>
  153. <section id="group.p.group_column">
  154. <title><varname>group_column</varname> (string)</title>
  155. <para>
  156. Name of the <quote>table</quote> column holding group names.
  157. </para>
  158. <para>
  159. <emphasis>
  160. Default value is <quote>grp</quote>.
  161. </emphasis>
  162. </para>
  163. <example>
  164. <title>Set <varname>group_column</varname> parameter</title>
  165. <programlisting format="linespecific">
  166. ...
  167. modparam("group", "group_column", "grp")
  168. ...
  169. </programlisting>
  170. </example>
  171. </section>
  172. <section id="group.p.use_domain">
  173. <title><varname>use_domain</varname> (integer)</title>
  174. <para>
  175. If enabled (set to a non zero value) then the domain will be used also used
  176. for strict group matching; otherwise only the username part will be
  177. used.
  178. </para>
  179. <para>
  180. <emphasis>
  181. Default value is 0 (disabled).
  182. </emphasis>
  183. </para>
  184. <example>
  185. <title>Set <varname>use_domain</varname> parameter</title>
  186. <programlisting format="linespecific">
  187. ...
  188. modparam("group", "use_domain", 1)
  189. ...
  190. </programlisting>
  191. </example>
  192. </section>
  193. <section id="group.p.re_table">
  194. <title><varname>re_table</varname> (string)</title>
  195. <para>
  196. Name of the table holding definitions for regular-expression
  197. based groups. If no table is defined, the regular-expression
  198. support is disabled.
  199. </para>
  200. <para>
  201. <emphasis>
  202. Default value is <quote>NULL</quote>.
  203. </emphasis>
  204. </para>
  205. <example>
  206. <title>Set <varname>re_table</varname> parameter</title>
  207. <programlisting format="linespecific">
  208. ...
  209. modparam("group", "re_table", "re_grp")
  210. ...
  211. </programlisting>
  212. </example>
  213. </section>
  214. <section id="group.p.re_exp_column">
  215. <title><varname>re_exp_column</varname> (string)</title>
  216. <para>
  217. Name of the <quote>re_table</quote> column holding the regular
  218. expression used for user matching.
  219. </para>
  220. <para>
  221. <emphasis>
  222. Default value is <quote>reg_exp</quote>.
  223. </emphasis>
  224. </para>
  225. <example>
  226. <title>Set <varname>re_exp_column</varname> parameter</title>
  227. <programlisting format="linespecific">
  228. ...
  229. modparam("group", "re_exp_column", "re")
  230. ...
  231. </programlisting>
  232. </example>
  233. </section>
  234. <section>
  235. <title><varname>re_gid_column</varname> (string)</title>
  236. <para>
  237. Name of the <quote>re_table</quote> column holding the group IDs.
  238. </para>
  239. <para>
  240. <emphasis>
  241. Default value is <quote>group_id</quote>.
  242. </emphasis>
  243. </para>
  244. <example>
  245. <title>Set <varname>re_gid_column</varname> parameter</title>
  246. <programlisting format="linespecific">
  247. ...
  248. modparam("group", "re_gid_column", "grp_id")
  249. ...
  250. </programlisting>
  251. </example>
  252. </section>
  253. <section id="group.p.multiple_gid">
  254. <title><varname>multiple_gid</varname> (integer)</title>
  255. <para>
  256. If enabled (non zero value) the regular-expression matching will
  257. return all group IDs that match the user; otherwise only the first
  258. will be returned.
  259. </para>
  260. <para>
  261. <emphasis>
  262. Default value is <quote>1</quote> (enabled).
  263. </emphasis>
  264. </para>
  265. <example>
  266. <title>Set <varname>multiple_gid</varname> parameter</title>
  267. <programlisting format="linespecific">
  268. ...
  269. modparam("group", "multiple_gid", 0)
  270. ...
  271. </programlisting>
  272. </example>
  273. </section>
  274. </section>
  275. <section>
  276. <title>Functions</title>
  277. <section id="group.f.is_user_in">
  278. <title>
  279. <function moreinfo="none">is_user_in(URI, group)</function>
  280. </title>
  281. <para>
  282. This function is to be used for script group membership. The function
  283. returns true if username in the given &uri; is a member of the given
  284. group and false if not.
  285. </para>
  286. <para>Meaning of the parameters is as follows:</para>
  287. <itemizedlist>
  288. <listitem>
  289. <para><emphasis>&uri;</emphasis> - &uri; whose username and
  290. optionally domain to be used, this can be one of:
  291. <itemizedlist>
  292. <listitem>
  293. <para>Request-URI - Use Request-URI username and
  294. (optionally) domain.</para>
  295. </listitem>
  296. <listitem>
  297. <para>To - Use To username and (optionally) domain.</para>
  298. </listitem>
  299. <listitem>
  300. <para>From - Use From username and (optionally) domain.</para>
  301. </listitem>
  302. <listitem>
  303. <para>Credentials - Use digest credentials username.</para>
  304. </listitem>
  305. <listitem>
  306. <para>$avp(name) - Use the URI from the AVP
  307. specified by this pseudo-variable.</para>
  308. </listitem>
  309. </itemizedlist>
  310. </para>
  311. </listitem>
  312. <listitem>
  313. <para><emphasis>group</emphasis> - Name of the group to check.
  314. </para>
  315. </listitem>
  316. </itemizedlist>
  317. <para>
  318. This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
  319. </para>
  320. <example>
  321. <title><function>is_user_in</function> usage</title>
  322. <programlisting format="linespecific">
  323. ...
  324. if (is_user_in("Request-URI", "ld")) {
  325. ...
  326. };
  327. ...
  328. </programlisting>
  329. </example>
  330. </section>
  331. <section id="group.f.get_user_group">
  332. <title>
  333. <function moreinfo="none">get_user_group(URI, AVP)</function>
  334. </title>
  335. <para>
  336. This function is to be used for regular expression based group
  337. membership. The function returns true if username in the given &uri;
  338. belongs to at least one group; the group ID(s) are returned as AVPs.
  339. </para>
  340. <para>Meaning of the parameters is as follows:</para>
  341. <itemizedlist>
  342. <listitem>
  343. <para><emphasis>&uri;</emphasis> - &uri; to be matched against
  344. the regular expressions:
  345. <itemizedlist>
  346. <listitem>
  347. <para>Request-URI - Use Request-URI</para>
  348. </listitem>
  349. <listitem>
  350. <para>To - Use To URI.</para>
  351. </listitem>
  352. <listitem>
  353. <para>From - Use From URI</para>
  354. </listitem>
  355. <listitem>
  356. <para>Credentials - Use digest credentials username
  357. and realm.</para>
  358. </listitem>
  359. <listitem>
  360. <para>$avp(name) - Use the URI from the AVP
  361. specified by this pseudo-variable.</para>
  362. </listitem>
  363. </itemizedlist>
  364. </para>
  365. </listitem>
  366. <listitem>
  367. <para><emphasis>AVP</emphasis> - $avp(name) - the matched group
  368. IDs are returned in this AVP.</para>
  369. </listitem>
  370. </itemizedlist>
  371. <para>
  372. This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
  373. </para>
  374. <example>
  375. <title><function>get_user_group</function> usage</title>
  376. <programlisting format="linespecific">
  377. ...
  378. if (get_user_group("Request-URI", "$avp(i:10)")) {
  379. xgdb("User $ru belongs to $(avp(i:10)[*]) group(s)\n");
  380. ....
  381. };
  382. ...
  383. </programlisting>
  384. </example>
  385. </section>
  386. </section>
  387. </chapter>