CVS update: php31/sapi
| From: | shane | Date: | Sun, 23 Aug 1998 06:29:14 +0000 |
| Subject: | CVS update: php31/sapi | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-523@lists.php.net to get a copy of this message | ||
Date: Sunday August 23, 1998 @ 2:29
Author: shane
Update of /repository/php31/sapi
In directory asf:/tmp/cvs-serv4028/sapi
Modified Files:
apache_sapi.c cgi_sapi.c isapi_sapi.c nsapi_sapi.c sapi.h
Log Message:
optimize authentication and move it back into php core.
Index: php31/sapi/apache_sapi.c
diff -c php31/sapi/apache_sapi.c:2.12 php31/sapi/apache_sapi.c:2.13
*** php31/sapi/apache_sapi.c:2.12 Sat Aug 22 14:31:03 1998
--- php31/sapi/apache_sapi.c Sun Aug 23 02:29:13 1998
***************
*** 216,284 ****
}
}
- void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V)
- {
- #if MODULE_MAGIC_NUMBER > 19961007
- const char *s = NULL;
- #else
- char *s = NULL;
- #endif
- char *t;
- char *user, *type;
- int len;
- char *escaped_str;
- SAPI_FUNC_VARS
-
- if (php3_rqst->headers_in)
- s = table_get(php3_rqst->headers_in, "Authorization");
- if (!s)
- return;
-
- /* Check to make sure that this URL isn't authenticated
- using a traditional auth module mechanism */
- if (auth_type(php3_rqst)) {
- /*php3_error(E_WARNING, "Authentication done by server module\n"); */
- return;
- }
- if (strcmp(getword(php3_rqst->pool, &s, ' '), "Basic")) {
- /* Client tried to authenticate using wrong auth scheme */
- php3_error(E_WARNING, "client used wrong authentication scheme", php3_rqst->uri,
php3_rqst);
- return;
- }
- t = uudecode(php3_rqst->pool, s);
- #if MODULE_MAGIC_NUMBER > 19961007
- user = getword_nulls_nc(php3_rqst->pool, &t, ':');
- #else
- user = getword(php3_rqst->pool, &t, ':');
- #endif
- type = "Basic";
-
- if (user) {
- if (GLOBAL(php3_ini)->magic_quotes_gpc) {
- escaped_str = _php3_addslashes(user, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_USER", escaped_str, len);
- } else {
- SET_VAR_STRING("PHP_AUTH_USER", estrdup(user));
- }
- }
- if (t) {
- if (GLOBAL(php3_ini)->magic_quotes_gpc) {
- escaped_str = _php3_addslashes(t, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_PW", escaped_str, len);
- } else {
- SET_VAR_STRING("PHP_AUTH_PW", estrdup(t));
- }
- }
- if (type) {
- if (GLOBAL(php3_ini)->magic_quotes_gpc) {
- escaped_str = _php3_addslashes(type, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_TYPE", escaped_str, len);
- } else {
- SET_VAR_STRING("PHP_AUTH_TYPE", estrdup(type));
- }
- }
- }
-
int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *string, int len)
{
SAPI_FUNC_VARS
--- 216,221 ----
***************
*** 560,565 ****
--- 497,503 ----
sapi_info->content_length = (buf ? atoi(buf) : 0);
sapi_info->cookies = table_get(php3_rqst->subprocess_env, "HTTP_COOKIE");
+ sapi_info->authorization = table_get(php3_rqst->headers_in, "Authorization");
sapi_info->getenv = sapi_getenv;
sapi_info->writeclient = sapi_writeclient;
***************
*** 573,579 ****
sapi_info->insert_header = sapi_insert_header;
sapi_info->send_header = sapi_send_header;
sapi_info->headers = NULL;
- sapi_info->treat_headers = sapi_treat_headers;
sapi_info->_php3_hash_server_env = sapi__php3_hash_server_env;
sapi_info->register_clean = sapi_register_cleanup;
--- 511,516 ----
Index: php31/sapi/cgi_sapi.c
diff -c php31/sapi/cgi_sapi.c:2.15 php31/sapi/cgi_sapi.c:2.16
*** php31/sapi/cgi_sapi.c:2.15 Fri Aug 21 17:00:46 1998
--- php31/sapi/cgi_sapi.c Sun Aug 23 02:29:14 1998
***************
*** 134,144 ****
}
- void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V)
- {
- }
-
-
#if defined(CRASH_DETECTION)
/* Crash detection logging */
void sapi_debug_log(SAPI_GLOBAL_INCLUDE char *message)
--- 134,139 ----
***************
*** 214,226 ****
sapi_info->content_length = (buf ? atoi(buf) : 0);
sapi_info->content_type = getenv("CONTENT_TYPE");
sapi_info->cookies = getenv("HTTP_COOKIE");
sapi_info->getenv = sapi_getenv;
sapi_info->writeclient = sapi_writeclient;
sapi_info->flush = sapi_flush;
sapi_info->insert_header = sapi_insert_header;
sapi_info->send_header = sapi_send_header;
- sapi_info->treat_headers = sapi_treat_headers;
sapi_info->readclient = sapi_readclient;
sapi_info->blockalarms = sapi_block;
sapi_info->unblockalarms = sapi_unblock;
--- 209,221 ----
sapi_info->content_length = (buf ? atoi(buf) : 0);
sapi_info->content_type = getenv("CONTENT_TYPE");
sapi_info->cookies = getenv("HTTP_COOKIE");
+ sapi_info->authorization=getenv("HTTP_AUTHORIZATION");
sapi_info->getenv = sapi_getenv;
sapi_info->writeclient = sapi_writeclient;
sapi_info->flush = sapi_flush;
sapi_info->insert_header = sapi_insert_header;
sapi_info->send_header = sapi_send_header;
sapi_info->readclient = sapi_readclient;
sapi_info->blockalarms = sapi_block;
sapi_info->unblockalarms = sapi_unblock;
Index: php31/sapi/isapi_sapi.c
diff -c php31/sapi/isapi_sapi.c:2.15 php31/sapi/isapi_sapi.c:2.16
*** php31/sapi/isapi_sapi.c:2.15 Fri Aug 21 17:54:13 1998
--- php31/sapi/isapi_sapi.c Sun Aug 23 02:29:14 1998
***************
*** 225,282 ****
return SUCCESS;
}
- void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V)
- {
- SAPI_FUNC_VARS;
- int len;
- char *escaped_str, *decoded, *r, *password;
- char *auth, *authinfo = sapi_getenv(SAPI_GLOBAL_PASS "HTTP_AUTHORIZATION");
- #ifdef DEBUG
- char logmessage[80];
- #endif
- if (!authinfo)
- return;
- if (strncmp("Basic ", authinfo, 6)) {
- efree(authinfo);
- return;
- }
- auth = authinfo + 6;
- decoded = _php3_base64_decode(auth, strlen(auth), &len);
- r = strchr(decoded, ':');
- if (r) {
- *r = '\0';
- password = r + 1;
- #ifdef DEBUG
- snprintf(logmessage, 79, "%d:sapi_treat_headers:decoded: %s - %s\n",
- GetCurrentThreadId(),
- decoded, password);
- OutputDebugString(logmessage);
- #endif
- if (decoded) {
- if (GLOBAL(php3_ini)->magic_quotes_gpc) {
- len = strlen(decoded);
- escaped_str = _php3_addslashes(decoded, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_USER", escaped_str, len);
- } else {
- SET_VAR_STRING("PHP_AUTH_USER", estrdup(decoded));
- }
- }
- if (password) {
- if (GLOBAL(php3_ini)->magic_quotes_gpc) {
- len = strlen(password);
- escaped_str = _php3_addslashes(password, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_PW", escaped_str, len);
- } else {
- SET_VAR_STRING("PHP_AUTH_PW", estrdup(password));
- }
- }
- *r = ':';
- efree(decoded);
- }
- SET_VAR_STRING("PHP_AUTH_TYPE", estrdup("Basic"));
- efree(authinfo);
- }
-
/* FIXME probably not used in isapi unless we buffer the page */
int sapi_flush(SAPI_GLOBAL_INCLUDE_V)
{
--- 225,230 ----
***************
*** 410,415 ****
--- 358,364 ----
sapi_info->content_length = lpEcb->cbTotalBytes;
sapi_info->content_type = lpEcb->lpszContentType;
sapi_info->cookies = _sapi_getenv(lpEcb, "HTTP_COOKIE");
+ sapi_info->authorization = _sapi_getenv(lpEcb, "HTTP_AUTHORIZATION");
sapi_info->getenv = sapi_getenv;
sapi_info->writeclient = sapi_writeclient;
***************
*** 422,428 ****
sapi_info->interactive = 0;
sapi_info->insert_header = sapi_insert_header;
- sapi_info->treat_headers = sapi_treat_headers;
sapi_info->send_header = sapi_send_header;
sapi_info->headers = NULL;
sapi_info->http_status = NULL;
--- 371,376 ----
Index: php31/sapi/nsapi_sapi.c
diff -c php31/sapi/nsapi_sapi.c:2.4 php31/sapi/nsapi_sapi.c:2.5
*** php31/sapi/nsapi_sapi.c:2.4 Sun Aug 23 02:03:36 1998
--- php31/sapi/nsapi_sapi.c Sun Aug 23 02:29:14 1998
***************
*** 374,465 ****
return strlen(authheader);
}
- int php3_nsapi_isvalid_auth(char *authstring)
- {
- if (strncmp("Basic ", authstring, 6))
- return 0;
- return 1;
- }
-
int EXPORT php3_nsapi_auth_trans(pblock * pb, Session * sn, Request * rq)
{
char AuthString[MAX_PATH];
return (php3_nsapi_has_auth(AuthString, rq) &&
! php3_nsapi_isvalid_auth(AuthString))
? REQ_PROCEED : REQ_ABORTED;
}
- void sapi_treat_headers(SAPI_GLOBAL_INCLUDE_V)
- {
- int len;
- char *escaped_str, *decoded, *r, *password, *authinfo, *auth;
- SAPI_FUNC_VARS;
-
- #ifdef DEBUG
- DEBUG_MESSAGE("enter sapi_treat_headers\n");
- #endif
- if (rq->headers)
- authinfo = pblock_findval("Authorization", rq->headers);
- if (!authinfo){
- #ifdef DEBUG
- DEBUG_MESSAGE("enter sapi_treat_headers, no auth\n");
- #endif
- return;
- }
- /* Check to make sure that this URL isn't authenticated
- using a traditional auth module mechanism
- Not yet sure how to do this with NSAPI
- if (auth_type(rq)) {
- return;
- }
- */
- if (strncmp("Basic ", authinfo, 6)) {
- #ifdef DEBUG
- DEBUG_MESSAGE("enter sapi_treat_headers, not basic\n");
- #endif
- return;
- }
- auth = authinfo + 6;
- decoded = _php3_base64_decode(auth, strlen(auth), &len);
- r = strchr(decoded, ':');
- if (r) {
- *r = '\0';
- password = r + 1;
- #ifdef DEBUG
- {
- char logmessage[1024];
- snprintf(logmessage, 79, "%d:sapi_treat_headers:decoded: %s - %s\n",
- GetCurrentThreadId(),
- decoded, password);
- OutputDebugString(logmessage);
- }
- #endif
- if (decoded) {
- if (GLOBAL(php3_ini)->magic_quotes_gpc) {
- len = strlen(decoded);
- escaped_str = _php3_addslashes(decoded, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_USER", escaped_str, len);
- } else {
- SET_VAR_STRING("PHP_AUTH_USER", estrdup(decoded));
- }
- }
- if (password) {
- if (GLOBAL(php3_ini)->magic_quotes_gpc) {
- len = strlen(password);
- escaped_str = _php3_addslashes(password, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_PW", escaped_str, len);
- } else {
- SET_VAR_STRING("PHP_AUTH_PW", estrdup(password));
- }
- }
- *r = ':';
- efree(decoded);
- }
- SET_VAR_STRING("PHP_AUTH_TYPE", estrdup("Basic"));
- #ifdef DEBUG
- DEBUG_MESSAGE("exit sapi_treat_headers\n");
- #endif
- }
/*********************************************************
/ input / output functions
--- 374,387 ----
return strlen(authheader);
}
int EXPORT php3_nsapi_auth_trans(pblock * pb, Session * sn, Request * rq)
{
char AuthString[MAX_PATH];
return (php3_nsapi_has_auth(AuthString, rq) &&
! !strncmp("Basic ", AuthString, 6))
? REQ_PROCEED : REQ_ABORTED;
}
/*********************************************************
/ input / output functions
***************
*** 620,625 ****
--- 542,548 ----
if(temp)sapi_info->content_length = atol(temp);
sapi_info->content_type = pblock_findval("content-type", rq->headers);
sapi_info->cookies = pblock_findval("cookie", rq->headers);
+ sapi_info->authorization = pblock_findval("authorization", rq->headers);
sapi_info->getenv = sapi_getenv;
sapi_info->writeclient = sapi_writeclient;
***************
*** 631,637 ****
sapi_info->info = sapi_print_info;
sapi_info->insert_header = sapi_insert_header;
- sapi_info->treat_headers = sapi_treat_headers;
sapi_info->send_header = sapi_send_header;
sapi_info->headers = NULL;
--- 554,559 ----
Index: php31/sapi/sapi.h
diff -c php31/sapi/sapi.h:2.12 php31/sapi/sapi.h:2.13
*** php31/sapi/sapi.h:2.12 Fri Aug 21 17:00:47 1998
--- php31/sapi/sapi.h Sun Aug 23 02:29:14 1998
***************
*** 46,51 ****
--- 46,52 ----
char *query_string;
char *request_method;
char *script_name;
+ char *authorization;
char *current_user;
int current_user_length;
unsigned int content_length;
***************
*** 64,70 ****
int http_redirect; /*used to signal redirect for isapi */
int (*insert_header) (SAPI_GLOBAL_INCLUDE unsigned char *); /*insert header into a list */
int (*send_header) (SAPI_GLOBAL_INCLUDE_V); /*write headers to client */
- void (*treat_headers) (SAPI_GLOBAL_INCLUDE_V);
/* io functions */
int (*readclient) (SAPI_GLOBAL_INCLUDE unsigned char *, int);
--- 65,70 ----
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net