auth.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <refentry id="refauth">
  2. <refmeta>
  3. <refentrytitle>ne_set_server_auth</refentrytitle>
  4. <manvolnum>3</manvolnum>
  5. </refmeta>
  6. <refnamediv>
  7. <refname id="ne_set_server_auth">ne_set_server_auth</refname>
  8. <refname id="ne_set_proxy_auth">ne_set_proxy_auth</refname>
  9. <refname id="ne_forget_auth">ne_forget_auth</refname>
  10. <refpurpose>register authentication callbacks</refpurpose>
  11. </refnamediv>
  12. <refsynopsisdiv>
  13. <funcsynopsis>
  14. <funcsynopsisinfo>#include &lt;ne_auth.h&gt;</funcsynopsisinfo>
  15. <funcprototype>
  16. <funcdef>typedef int (*<function>ne_auth_creds</function>)</funcdef>
  17. <paramdef>void *<parameter>userdata</parameter></paramdef>
  18. <paramdef>const char *<parameter>realm</parameter></paramdef>
  19. <paramdef>int <parameter>attempt</parameter></paramdef>
  20. <paramdef>char *<parameter>username</parameter></paramdef>
  21. <paramdef>char *<parameter>password</parameter></paramdef>
  22. </funcprototype>
  23. <funcprototype>
  24. <funcdef>void <function>ne_set_server_auth</function></funcdef>
  25. <paramdef>ne_session *<parameter>session</parameter></paramdef>
  26. <paramdef>ne_auth_creds <parameter>callback</parameter></paramdef>
  27. <paramdef>void *<parameter>userdata</parameter></paramdef>
  28. </funcprototype>
  29. <funcprototype>
  30. <funcdef>void <function>ne_set_proxy_auth</function></funcdef>
  31. <paramdef>ne_session *<parameter>session</parameter></paramdef>
  32. <paramdef>ne_auth_creds <parameter>callback</parameter></paramdef>
  33. <paramdef>void *<parameter>userdata</parameter></paramdef>
  34. </funcprototype>
  35. <funcprototype>
  36. <funcdef>void <function>ne_forget_auth</function></funcdef>
  37. <paramdef>ne_session *<parameter>session</parameter></paramdef>
  38. </funcprototype>
  39. </funcsynopsis>
  40. </refsynopsisdiv>
  41. <refsect1>
  42. <title>Description</title>
  43. <para>The <type>ne_auth_creds</type> function type defines a
  44. callback which is invoked when a server or proxy server requires user
  45. authentication for a particular request. The
  46. <parameter>realm</parameter> string is supplied by the server. <!--
  47. FIXME --> The <parameter>attempt</parameter> is a counter giving the
  48. number of times the request has been retried with different
  49. authentication credentials. The first time the callback is invoked
  50. for a particular request, <parameter>attempt</parameter> will be zero.</para>
  51. <para>To retry the request using new authentication
  52. credentials, the callback should return zero, and the
  53. <parameter>username</parameter> and <parameter>password</parameter>
  54. buffers must contain &nul;-terminated strings. The
  55. <literal>NE_ABUFSIZ</literal> constant gives the size of these
  56. buffers.</para>
  57. <tip>
  58. <para>If you only wish to allow the user one attempt to enter
  59. credentials, use the value of the <parameter>attempt</parameter>
  60. parameter as the return value of the callback.</para>
  61. </tip>
  62. <para>To abort the request, the callback should return a
  63. non-zero value; in which case the contents of the
  64. <parameter>username</parameter> and <parameter>password</parameter>
  65. buffers are ignored.</para>
  66. <para>The <function>ne_forget_auth</function> function can be
  67. used to discard the cached authentication credentials.</para>
  68. </refsect1>
  69. <refsect1>
  70. <title>Examples</title>
  71. <programlisting>
  72. /* Function which prompts for a line of user input: */
  73. extern char *prompt_for(const char *prompt);
  74. static int
  75. my_auth(void *userdata, const char *realm, int attempts,
  76. char *username, char *password)
  77. {
  78. strncpy(username, prompt_for("Username: "), NE_ABUFSIZ);
  79. strncpy(password, prompt_for("Password: "), NE_ABUFSIZ);
  80. return attempts;
  81. }
  82. int main(...)
  83. {
  84. &egsess;
  85. ne_set_server_auth(sess, my_auth, NULL);
  86. /* ... */
  87. }</programlisting>
  88. </refsect1>
  89. </refentry>