1NE_SET_SERVER_AUTH(3)         neon API reference         NE_SET_SERVER_AUTH(3)
2
3
4

NAME

6       ne_set_server_auth,   ne_set_proxy_auth,   ne_forget_auth   -  register
7       authentication callbacks
8

SYNOPSIS

10       #include <ne_auth.h>
11
12
13       typedef int (*ne_request_auth) (void *userdata, const char *realm,
14                                        int attempt, char *username,
15                                        char *password);
16
17       void ne_set_server_auth (ne_session *session, ne_request_auth callback,
18                                void *userdata);
19
20       void ne_set_proxy_auth (ne_session *session, ne_request_auth callback,
21                               void *userdata);
22
23       void ne_forget_auth (ne_session *session);
24
25

DESCRIPTION

27       The ne_request_auth function type defines a callback which  is  invoked
28       when  a  server or proxy server requires user authentication for a par‐
29       ticular request. The realm string is supplied by the server.   The  at‐
30       tempt  is a counter giving the number of times the request has been re‐
31       tried with different authentication credentials.  The  first  time  the
32       callback is invoked for a particular request, attempt will be zero.
33
34
35       To retry the request using new authentication credentials, the callback
36       should return zero, and the username and password buffers must  contain
37       NUL-terminated strings. The NE_ABUFSIZ constant gives the size of these
38       buffers.
39
40
41              Tip
42
43              If you only wish to allow the user one attempt to enter  creden‐
44              tials, use the value of the attempt parameter as the return val‐
45              ue of the callback.
46
47
48
49       To abort the request, the callback should return a non-zero  value;  in
50       which  case  the  contents of the username and password buffers are ig‐
51       nored.
52
53
54       The ne_forget_auth function can be used to discard the cached authenti‐
55       cation credentials.
56
57

EXAMPLES

59       /* Function which prompts for a line of user input: */
60       extern char *prompt_for(const char *prompt);
61
62       static int
63       my_auth(void *userdata, const char *realm, int attempts,
64               char *username, char *password)
65       {
66          strncpy(username, prompt_for("Username: "), NE_ABUFSIZ);
67          strncpy(password, prompt_for("Password: "), NE_ABUFSIZ);
68          return attempts;
69       }
70
71       int main(...)
72       {
73          ne_session *sess = ne_session_create(...);
74
75          ne_set_server_auth(sess, my_auth, NULL);
76
77          /* ... */
78       }
79
80

AUTHOR

82       Joe Orton <neon@webdav.org>.
83
84
85
86neon 0.25.5                     20 January 2006          NE_SET_SERVER_AUTH(3)
Impressum