auth_tag.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /*
  2. * This file is part of the Sofia-SIP package
  3. *
  4. * Copyright (C) 2005 Nokia Corporation.
  5. *
  6. * Contact: Pekka Pessi <pekka.pessi@nokia.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public License
  10. * as published by the Free Software Foundation; either version 2.1 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. /**@CFILE auth_tag.c
  25. * @brief Tags for authentication verification module for NTA servers.
  26. *
  27. * @author Pekka Pessi <Pekka.Pessi@nokia.com>.
  28. *
  29. * @date Created: Wed Apr 11 15:14:03 2001 ppessi
  30. */
  31. #include "config.h"
  32. #define TAG_NAMESPACE "auth"
  33. #include "sofia-sip/auth_module.h"
  34. #include <sofia-sip/su_tag_class.h>
  35. #include <sofia-sip/url_tag_class.h>
  36. /**@def AUTHTAG_ANY()
  37. *
  38. * Filter tag matching any AUTHTAG_*().
  39. */
  40. tag_typedef_t authtag_any = NSTAG_TYPEDEF(*);
  41. /**@def AUTHTAG_MODULE()
  42. *
  43. * Pointer to an authentication server module (auth_mod_t).
  44. *
  45. * The tag item AUTHTAG_MODULE() contains pointer to an authentication server
  46. * module. It is used to pass an already initialized authentication module
  47. * to a server object (like web server or registrar object).
  48. */
  49. tag_typedef_t authtag_module = PTRTAG_TYPEDEF(module);
  50. /**@def AUTHTAG_METHOD()
  51. *
  52. * Name of the authentication scheme.
  53. *
  54. * The tag AUTHTAG_METHOD() specifies the authentication module and scheme
  55. * to be used by the auth_module. The name can specify a basic
  56. * authentication module, like "Digest" or "Basic", or an plugin module,
  57. * like "SGMF+Digest".
  58. *
  59. * @sa See <sofia-sip/auth_plugin.h> for plugin interface.
  60. */
  61. tag_typedef_t authtag_method = STRTAG_TYPEDEF(method);
  62. /**@def AUTHTAG_REALM()
  63. *
  64. * Authentication realm used by authentication server.
  65. *
  66. * The tag authtag_method specifies the authentication realm used by the @b
  67. * auth_module. For servers, the domain name in the request URI is inserted
  68. * in the realm returned to the client if the realm string contains an
  69. * asterisk @c "*". Only the first asterisk is replaced by request domain
  70. * name.
  71. *
  72. * @p Default Value
  73. * "*".
  74. */
  75. tag_typedef_t authtag_realm = STRTAG_TYPEDEF(realm);
  76. /**@def AUTHTAG_OPAQUE()
  77. *
  78. * Opaque data used by authentication server.
  79. *
  80. * The tag authtag_opaque is used to pass opaque data to the @b auth_module.
  81. * The opaque data will be included in all the challenges (however, the data
  82. * is prefixed with a "." and other opaque data used by the algorithms.
  83. *
  84. * @p Default Value
  85. * "".
  86. */
  87. tag_typedef_t authtag_opaque = STRTAG_TYPEDEF(opaque);
  88. /**@def AUTHTAG_DB()
  89. *
  90. * Name of authentication database used by authentication server.
  91. *
  92. * The tag AUTHTAG_DB() specifies the file name used to store the
  93. * authentication data. The file contains triplets as follows:
  94. *
  95. * @code
  96. * user:password:realm
  97. * @endcode
  98. *
  99. * @note
  100. * Currently, the passwords are stored as plaintext.
  101. */
  102. tag_typedef_t authtag_db = STRTAG_TYPEDEF(db);
  103. /**@def AUTHTAG_QOP()
  104. *
  105. * Quality-of-protection used by Digest authentication.
  106. *
  107. * The tag AUTHTAG_QOP() specifies the qop scheme to be used by the
  108. * digest authentication.
  109. */
  110. tag_typedef_t authtag_qop = STRTAG_TYPEDEF(qop);
  111. /**@def AUTHTAG_ALGORITHM()
  112. *
  113. * Authentication algorithm used by Digest authentication.
  114. *
  115. * The tag AUTHTAG_ALGORITHM() specifies the qop scheme to be used by the
  116. * digest authentication.
  117. */
  118. tag_typedef_t authtag_algorithm = STRTAG_TYPEDEF(algorithm);
  119. /**@def AUTHTAG_EXPIRES()
  120. *
  121. * Nonce expiration time for Digest authentication.
  122. *
  123. * The tag AUTHTAG_EXPIRES() specifies the time in seconds that a nonce is
  124. * considered valid. If 0, the nonce lifetime unbounded. The default time is
  125. * 3600 seconds.
  126. */
  127. tag_typedef_t authtag_expires = UINTTAG_TYPEDEF(expires);
  128. /**@def AUTHTAG_NEXT_EXPIRES()
  129. *
  130. * Next nonce expiration time for Digest authentication.
  131. *
  132. * The tag AUTHTAG_NEXT_EXPIRES() specifies the time in seconds that a
  133. * nextnonce sent in Authentication-Info header is considered valid. If 0,
  134. * the nonce lifetime is unbounded. The default time is 3600 seconds.
  135. */
  136. tag_typedef_t authtag_next_expires = UINTTAG_TYPEDEF(next_expires);
  137. /**@def AUTHTAG_MAX_NCOUNT()
  138. *
  139. * Max nonce count value.
  140. *
  141. * The tag AUTHTAG_MAX_NCOUNT() specifies the maximum number of times a
  142. * nonce should be used.
  143. *
  144. * @todo Count actual usages and don't trust "nc" parameter only.
  145. */
  146. tag_typedef_t authtag_max_ncount = UINTTAG_TYPEDEF(max_ncount);
  147. /**@def AUTHTAG_BLACKLIST()
  148. *
  149. * Blacklist time.
  150. *
  151. * The tag AUTHTAG_BLACKLIST() specifies the time the server delays its
  152. * response if it is given bad credentials or malformed nonce. The default
  153. * time is 5 seconds.
  154. *
  155. * @todo Implement delayed response.
  156. */
  157. tag_typedef_t authtag_blacklist = UINTTAG_TYPEDEF(blacklist);
  158. /**@def AUTHTAG_FORBIDDEN()
  159. *
  160. * Respond with 403 Forbidden.
  161. *
  162. * When given a true argument, the tag AUTHTAG_FORBIDDEN() specifies that the
  163. * server responds with 403 Forbidden (instead of 401/407) when it receives
  164. * bad credentials.
  165. */
  166. tag_typedef_t authtag_forbidden = BOOLTAG_TYPEDEF(forbidden);
  167. /**@def AUTHTAG_ANONYMOUS()
  168. *
  169. * Allow anonymous access.
  170. *
  171. * When given a true argument, the tag AUTHTAG_ANONYMOUS() allows
  172. * authentication module to accept the account "anonymous" with an empty
  173. * password. The auth_status_t::as_anonymous flag is set in auth_status_t
  174. * structure after anonymous authentication.
  175. */
  176. tag_typedef_t authtag_anonymous = BOOLTAG_TYPEDEF(anonymous);
  177. /**@def AUTHTAG_FAKE()
  178. *
  179. * Fake authentication process.
  180. *
  181. * When given a true argument, the tag AUTHTAG_FAKE() causes authentication
  182. * module to allow access with any password when the username is valid. The
  183. * auth_status_t::as_fake flag is set in auth_status_t structure after a
  184. * fake authentication.
  185. */
  186. tag_typedef_t authtag_fake = BOOLTAG_TYPEDEF(fake);
  187. /**@def AUTHTAG_REMOTE()
  188. *
  189. * Remote authenticator URL.
  190. *
  191. * The tag AUTHTAG_REMOTE() is used to specify URL for remote authenticator.
  192. * The meaning of the URL is specific to the authentication module. The
  193. * authentication module is selected by AUTHTAG_METHOD().
  194. */
  195. tag_typedef_t authtag_remote = URLTAG_TYPEDEF(remote);
  196. /**@def AUTHTAG_ALLOW()
  197. *
  198. * Comma-separated list of methods that are not challenged.
  199. *
  200. * The tag AUTHTAG_ALLOW() takes its argument a string containing a
  201. * comma-separated list of methods, for example,
  202. * @code
  203. * AUTHTAG_ALLOW("ACK, BYE, CANCEL").
  204. * @endcode
  205. *
  206. * The specified methods are not challenged by the authentication module.
  207. * For example, this may include SIP ACK method or SIP methods only used
  208. * within an already established dialog.
  209. */
  210. tag_typedef_t authtag_allow = STRTAG_TYPEDEF(allow);
  211. /**@def AUTHTAG_MASTER_KEY()
  212. *
  213. * Private master key for the authentication module.
  214. *
  215. * The tag AUTHTAG_MASTER_KEY() specifies a private master key that can be
  216. * used by the authentication module for various purposes (for instance,
  217. * validating that nonces are really generated by it).
  218. */
  219. tag_typedef_t authtag_master_key = STRTAG_TYPEDEF(master_key);
  220. /**@def AUTHTAG_CACHE_USERS()
  221. *
  222. * Time to cache user data.
  223. *
  224. * The tag AUTHTAG_CACHE_USERS() specifies how many seconds the user data is
  225. * cached locally. Default value is typically 30 minutes.
  226. */
  227. tag_typedef_t authtag_cache_users = UINTTAG_TYPEDEF(cache_users);
  228. /**@def AUTHTAG_CACHE_ERRORS()
  229. *
  230. * Time to cache errors.
  231. *
  232. * The tag AUTHTAG_CACHE_ERRORS() specifies the lifetime in seconds for
  233. * errors in the local authentication data cache. Note that the errors
  234. * generated locally (e.g., because of connectivity problem with
  235. * authentication server) have maximum lifetime of 2 minutes.
  236. */
  237. tag_typedef_t authtag_cache_errors = UINTTAG_TYPEDEF(cache_errors);