--------------------- PatchSet 859 Date: 2000/11/20 22:40:33 Author: rbcollins Branch: auth_rewrite Tag: (none) Log: halfway to complete modularisation Members: src/authenticate.c:1.1.1.3.12.17.2.3->1.1.1.3.12.17.2.4 src/structs.h:1.1.1.3.4.1.2.26.2.2->1.1.1.3.4.1.2.26.2.3 src/typedefs.h:1.1.1.3.12.13.2.2->1.1.1.3.12.13.2.3 src/auth/basic/auth_basic.c:1.1.2.1->1.1.2.2 src/auth/ntlm/auth_ntlm.c:1.1.2.1->1.1.2.2 Index: squid/src/authenticate.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/authenticate.c,v retrieving revision 1.1.1.3.12.17.2.3 retrieving revision 1.1.1.3.12.17.2.4 diff -u -r1.1.1.3.12.17.2.3 -r1.1.1.3.12.17.2.4 --- squid/src/authenticate.c 20 Nov 2000 13:18:03 -0000 1.1.1.3.12.17.2.3 +++ squid/src/authenticate.c 20 Nov 2000 22:40:33 -0000 1.1.1.3.12.17.2.4 @@ -1,6 +1,6 @@ /* - * $Id: authenticate.c,v 1.1.1.3.12.17.2.3 2000/11/20 13:18:03 rbcollins Exp $ + * $Id: authenticate.c,v 1.1.1.3.12.17.2.4 2000/11/20 22:40:33 rbcollins Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Duane Wessels @@ -58,8 +58,9 @@ acl_proxy_auth_user *auth_user; RH *handler; } authenticateStateData; - +#if 0 static void authenticateStateFree(authenticateStateData * r); +#endif static void authenticateDecodeAuth(const char *proxy_auth, acl_proxy_auth_user * auth_user); @@ -142,7 +143,7 @@ } #endif } - +#if 0 static void authenticateStateFree(authenticateStateData * r) { @@ -200,7 +201,7 @@ auth_user->ip_expiretime = squid_curtime; return auth_user; } -#if 0 + int authenticateBasicDirection(acl_proxy_auth_user *auth_user) { /* null auth_user is checked for by authenticateDirection */ switch (auth_user->flags.credentials_ok) { @@ -479,8 +480,8 @@ { cbdataFree(r); } -#endif -#if 0 + + static void authenticateNTLMStats(StoreEntry * sentry) { @@ -700,7 +701,7 @@ debug (29, 7) ("Couldn't find user in cache: assuming not logged in.\n"); return 0; } - +#if 0 static acl_proxy_auth_user * authenticateNTLMAuthenticateUser(void *data, const char * proxy_auth, ConnStateData *conn) { acl_proxy_auth_user *auth_user=data; @@ -874,7 +875,7 @@ return auth_user; } - +#endif /* * authenticateAuthenticateUser: log this user in returns a new auth_user. @@ -883,8 +884,16 @@ */ acl_proxy_auth_user * authenticateAuthenticateUser(acl_proxy_auth_user *auth_user, request_t *request, ConnStateData *conn, http_hdr_type type) { +#if 0 const char * proxy_auth; +#endif assert(auth_user !=NULL); + if (auth_user->auth_module>0) + return authscheme_list[auth_user->auth_module-1].authAuthenticate(auth_user, request, conn, type); + return auth_user; + + +#if 0 proxy_auth = httpHeaderGetStr(&request->header, type); debug(29,6) ("authenticateAuthenticateUser: authentication header type %d, value '%s'\n.", type,proxy_auth); /* switch used so we get warn-on-compile if new AUTH type added but not @@ -904,11 +913,17 @@ } /*identity function */ return auth_user; +#endif } /* authenticateUserUsername: return a pointer to the username in the */ char * authenticateUserUsername(acl_proxy_auth_user *auth_user) { + assert (auth_user !=NULL); + if (auth_user->auth_module>0) + return authscheme_list[auth_user->auth_module-1].authUserUsername(auth_user); + return NULL; +#if 0 switch (auth_user->auth_type) { case AUTH_UNKNOWN: case AUTH_BROKEN: @@ -922,6 +937,7 @@ break; } return NULL; +#endif } /* returns Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.1.1.3.4.1.2.26.2.2 retrieving revision 1.1.1.3.4.1.2.26.2.3 diff -u -r1.1.1.3.4.1.2.26.2.2 -r1.1.1.3.4.1.2.26.2.3 --- squid/src/structs.h 20 Nov 2000 13:18:04 -0000 1.1.1.3.4.1.2.26.2.2 +++ squid/src/structs.h 20 Nov 2000 22:40:33 -0000 1.1.1.3.4.1.2.26.2.3 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.1.1.3.4.1.2.26.2.2 2000/11/20 13:18:04 rbcollins Exp $ + * $Id: structs.h,v 1.1.1.3.4.1.2.26.2.3 2000/11/20 22:40:33 rbcollins Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -134,6 +134,8 @@ char *typestr; // STFSPARSE *parsefunc; // STFSRECONFIGURE *reconfigurefunc; + AUTHSAUTHUSER *authAuthenticate; + AUTHSUSERNAME *authUserUsername; AUTHSONCLOSEC *oncloseconnection; AUTHSDECODE *decodeauth; AUTHSDIRECTION *getdirection; Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.1.1.3.12.13.2.2 retrieving revision 1.1.1.3.12.13.2.3 diff -u -r1.1.1.3.12.13.2.2 -r1.1.1.3.12.13.2.3 --- squid/src/typedefs.h 20 Nov 2000 13:18:04 -0000 1.1.1.3.12.13.2.2 +++ squid/src/typedefs.h 20 Nov 2000 22:40:33 -0000 1.1.1.3.12.13.2.3 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.1.1.3.12.13.2.2 2000/11/20 13:18:04 rbcollins Exp $ + * $Id: typedefs.h,v 1.1.1.3.12.13.2.3 2000/11/20 22:40:33 rbcollins Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -290,13 +290,15 @@ typedef void StatHistBinDumper(StoreEntry *, int idx, double val, double size, int count); /* authenticate.c authenticate scheme routines typedefs */ -typedef void AUTHSDECODE(acl_proxy_auth_user *, const char *); -typedef int AUTHSDIRECTION(acl_proxy_auth_user *); -typedef void AUTHSONCLOSEC(acl_proxy_auth_user *); -typedef void AUTHSSETUP(authscheme_entry_t *); -typedef void AUTHSSHUTDOWN(void); -typedef void AUTHSSTART(acl_proxy_auth_user * , RH * , void *); -typedef void AUTHSSTATS(StoreEntry *); +typedef acl_proxy_auth_user * AUTHSAUTHUSER(acl_proxy_auth_user *, request_t *, ConnStateData *, http_hdr_type); +typedef void AUTHSDECODE(acl_proxy_auth_user *, const char *); +typedef int AUTHSDIRECTION(acl_proxy_auth_user *); +typedef char *AUTHSUSERNAME(acl_proxy_auth_user *); +typedef void AUTHSONCLOSEC(acl_proxy_auth_user *); +typedef void AUTHSSETUP(authscheme_entry_t *); +typedef void AUTHSSHUTDOWN(void); +typedef void AUTHSSTART(acl_proxy_auth_user * , RH * , void *); +typedef void AUTHSSTATS(StoreEntry *); /* append/vprintf's for Packer */ typedef void (*append_f) (void *, const char *buf, int size); Index: squid/src/auth/basic/auth_basic.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/basic/auth_basic.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/src/auth/basic/auth_basic.c 20 Nov 2000 13:18:04 -0000 1.1.2.1 +++ squid/src/auth/basic/auth_basic.c 20 Nov 2000 22:40:33 -0000 1.1.2.2 @@ -69,10 +69,12 @@ static void authenticateBasicStart(acl_proxy_auth_user *, RH *, void *); static HLPCB authenticateBasicHandleReply; +static AUTHSAUTHUSER authenticateBasicAuthenticateUser; static AUTHSDIRECTION authenticateBasicDirection; static AUTHSDECODE authenticateBasicDecodeAuth; static AUTHSSTART authenticateBasicStart; static AUTHSSTATS authenticateBasicStats; +static AUTHSUSERNAME authenticateBasicUsername; static helper *basicauthenticators = NULL; @@ -101,8 +103,10 @@ assert(!authbasic_initialised); // authscheme->parsefunc = storeUfsDirParse; // authscheme->reconfigurefunc = storeUfsDirReconfigure; + authscheme->authAuthenticate = authenticateBasicAuthenticateUser; authscheme->authStart =authenticateBasicStart; authscheme->authStats =authenticateBasicStats; + authscheme->authUserUsername = authenticateBasicUsername; authscheme->getdirection=authenticateBasicDirection; authscheme->oncloseconnection=NULL; authscheme->decodeauth =authenticateBasicDecodeAuth; @@ -128,13 +132,20 @@ /* log a basic user in */ static acl_proxy_auth_user * +authenticateBasicAuthenticateUser(acl_proxy_auth_user *auth_user, request_t *request, ConnStateData *conn, http_hdr_type type) { +#if 0 authenticateBasicAuthenticateUser(acl_proxy_auth_user *data, const char * proxy_auth) { +#endif acl_proxy_auth_hash_pointer *usernamehash, *proxy_auth_hash=NULL; - acl_proxy_auth_user *auth_user=data; + const char * proxy_auth; +// acl_proxy_auth_user *auth_user=data; /* if the password is not ok, do an identity */ if (auth_user->flags.credentials_ok!=1) return auth_user; + /* get the header. */ + proxy_auth = httpHeaderGetStr(&request->header, type); + /* password was checked and did match */ debug(29, 4) ("authenticateBasicAuthenticateuser: user '%s' validated OK\n", auth_user->auth_data.basic_auth.username); @@ -229,6 +240,15 @@ helperStats(sentry, basicauthenticators); } + +/* authenticateBasicUsername: return a pointer to the username in the */ +char * +authenticateBasicUsername(acl_proxy_auth_user *auth_user) { + if (auth_user->auth_type==AUTH_BASIC) + return auth_user->auth_data.basic_auth.username; + return NULL; +} + /* * Decode a Basic [Proxy-]Auth string, placing the results in the passed * Auth_user structure. Index: squid/src/auth/ntlm/auth_ntlm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/ntlm/auth_ntlm.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/src/auth/ntlm/auth_ntlm.c 20 Nov 2000 13:18:04 -0000 1.1.2.1 +++ squid/src/auth/ntlm/auth_ntlm.c 20 Nov 2000 22:40:34 -0000 1.1.2.2 @@ -68,9 +68,11 @@ /* NTLM Scheme */ static void authenticateNTLMStart(acl_proxy_auth_user *, RH * handler, void *); static HLPSCB authenticateNTLMHandleReply; +static AUTHSAUTHUSER authenticateNTLMAuthenticateUser; static AUTHSDIRECTION authenticateNTLMDirection; static AUTHSDECODE authenticateDecodeNTLMAuth; static AUTHSONCLOSEC authenticateNTLMOnCloseConnection; +static AUTHSUSERNAME authenticateNTLMUsername; static AUTHSSTART authenticateNTLMStart; static AUTHSSTATS authenticateNTLMStats; @@ -104,8 +106,10 @@ assert(!authntlm_initialised); // authscheme->parsefunc = storeUfsDirParse; // authscheme->reconfigurefunc = storeUfsDirReconfigure; + authscheme->authAuthenticate = authenticateNTLMAuthenticateUser; authscheme->authStart =authenticateNTLMStart; authscheme->authStats =authenticateNTLMStats; + authscheme->authUserUsername = authenticateNTLMUsername; authscheme->getdirection=authenticateNTLMDirection; authscheme->decodeauth =authenticateDecodeNTLMAuth; authscheme->donefunc = authNTLMDone; @@ -376,6 +380,16 @@ } #endif + +/* authenticateUserUsername: return a pointer to the username in the */ +char * +authenticateNTLMUsername(acl_proxy_auth_user *auth_user) { + if(auth_user->auth_type== AUTH_NTLM) + return auth_user->auth_data.ntlm_auth.username; + return NULL; +} + + /* * Decode an NTLM [Proxy-]Auth string, placing the results in the passed * Auth_user structure. @@ -390,12 +404,20 @@ return; } +#if 0 static acl_proxy_auth_user * authenticateNTLMAuthenticateUser(void *data, const char * proxy_auth, ConnStateData *conn) { - acl_proxy_auth_user *auth_user=data; +#endif +static acl_proxy_auth_user * +authenticateNTLMAuthenticateUser(acl_proxy_auth_user *auth_user, request_t *request, ConnStateData *conn, http_hdr_type type) { +// acl_proxy_auth_user *auth_user=data; + const char * proxy_auth; acl_proxy_auth_hash_pointer *usernamehash, *proxy_auth_hash=NULL; LOCAL_ARRAY(char, ntlmhash, NTLM_CHALLENGE_SZ * 2); // char * proxy_auth=auth_user->proxy_auth; + /* get header */ + proxy_auth = httpHeaderGetStr(&request->header, type); + assert(auth_user->auth_type==AUTH_NTLM); switch (auth_user->auth_data.ntlm_auth.auth_state) { case AUTHENTICATE_STATE_NONE: