1 /* 2 HTTP authentication routines 3 Copyright (C) 1999-2002, Joe Orton <joe@manyfish.co.uk> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public 16 License along with this library; if not, write to the Free 17 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 MA 02111-1307, USA 19 20 */ 21 22 #ifndef NE_AUTH_H 23 #define NE_AUTH_H 24 25 #include "ne_session.h" /* for ne_session */ 26 27 BEGIN_NEON_DECLS 28 29 /* Size of username/password buffers passed to ne_auth_creds 30 * callback. */ 31 #define NE_ABUFSIZ (256) 32 33 /* The callback used to request the username and password in the given 34 * realm. The username and password must be copied into the buffers 35 * which are both of size NE_ABUFSIZ. The 'attempt' parameter is zero 36 * on the first call to the callback, and increases by one each time 37 * an attempt to authenticate fails. 38 * 39 * The callback must return zero to indicate that authentication 40 * should be attempted with the username/password, or non-zero to 41 * cancel the request. (if non-zero, username and password are 42 * ignored.) */ 43 typedef int (*ne_auth_creds)(void *userdata, const char *realm, int attempt, 44 char *username, char *password); 45 46 /* TOP TIP: if you just wish to try authenticating once (even if the 47 * user gets the username/password wrong), have your implementation of 48 * the callback return the 'attempt' value. */ 49 50 /* Set callbacks to provide credentials for server and proxy 51 * authentication. userdata is passed as the first argument to the 52 * callback. The callback is called *indefinitely* until either it 53 * returns non-zero, or authentication is successful. */ 54 void ne_set_server_auth(ne_session *sess, ne_auth_creds creds, void *userdata); 55 void ne_set_proxy_auth(ne_session *sess, ne_auth_creds creds, void *userdata); 56 57 /* Clear any stored authentication details for the given session. */ 58 void ne_forget_auth(ne_session *sess); 59 60 END_NEON_DECLS 61 62 #endif /* NE_AUTH_H */ 63