]> granicus.if.org Git - php/commitdiff
added a server variable PHP_AUTH_DIGEST to support HTTP Digest Authentication.
authorRui Hirokawa <hirokawa@php.net>
Mon, 4 Apr 2005 15:06:36 +0000 (15:06 +0000)
committerRui Hirokawa <hirokawa@php.net>
Mon, 4 Apr 2005 15:06:36 +0000 (15:06 +0000)
main/SAPI.c
main/SAPI.h
main/main.c
main/php_variables.c
sapi/apache/mod_php5.c
sapi/apache_hooks/mod_php5.c

index 5ff76c35b29aa6344d7c28231bf3d090e6299bf2..e6ce825375f9ed63157025ab6792463d19d30cc4 100644 (file)
@@ -424,6 +424,9 @@ SAPI_API void sapi_deactivate(TSRMLS_D)
        if (SG(request_info).auth_password) {
                efree(SG(request_info).auth_password);
        }
+       if (SG(request_info).auth_digest) {
+               efree(SG(request_info).auth_digest);
+       }
        if (SG(request_info).content_type_dup) {
                efree(SG(request_info).content_type_dup);
        }
index 9ef7eecbdb39cb2a8b7448845455c3c81549fbb1..3b132b8080879cb191ecdb5295f01d2a35ed5ae5 100644 (file)
@@ -98,6 +98,7 @@ typedef struct {
        /* for HTTP authentication */
        char *auth_user;
        char *auth_password;
+       char *auth_digest;
 
        /* this is necessary for the CGI SAPI module */
        char *argv0;
index e310abd7c44428a0b9b4df1f3b93c80a40706b53..e0ed5c37569194e3df532ec1ec5990b49df9c85d 100644 (file)
@@ -1736,6 +1736,11 @@ PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC)
                SG(request_info).auth_user = SG(request_info).auth_password = NULL;
        }
        
+       if (auth && auth[0] != '\0' && strncmp(auth, "Digest ", 7) == 0) {
+               SG(request_info).auth_digest = estrdup(auth);
+               ret = 0;
+       }
+
        return ret;
 }
 /* }}} */
index 17a0d82592770587e06f5dc3beef1d1338ab2a69..95995c2e399f71e77203a7eb74f18fc7c91c1179 100644 (file)
@@ -515,6 +515,9 @@ static inline void php_register_server_variables(TSRMLS_D)
        if (SG(request_info).auth_password) {
                php_register_variable("PHP_AUTH_PW", SG(request_info).auth_password, array_ptr TSRMLS_CC);
        }
+       if (SG(request_info).auth_digest) {
+               php_register_variable("PHP_AUTH_DIGEST", SG(request_info).auth_digest, array_ptr TSRMLS_CC);
+       }
        /* store request init time */
        {
                zval new_entry;
index 59be19df4bac0115c7ac02915e7f8bec68c8af2a..6fc4016c19e7f26c3577632452790c1701fbaf89 100644 (file)
@@ -489,24 +489,27 @@ static void init_request_info(TSRMLS_D)
        if (r->headers_in) {
                authorization = table_get(r->headers_in, "Authorization");
        }
+
+       SG(request_info).auth_user = NULL;
+       SG(request_info).auth_password = NULL;
+
        if (authorization
-               && (!PG(safe_mode) || (PG(safe_mode) && !auth_type(r)))
-               && !strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
-               tmp = uudecode(r->pool, authorization);
-               SG(request_info).auth_user = NULL;
-               tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
-               if (tmp_user) {
-                       r->connection->user = pstrdup(r->connection->pool, tmp_user);
-                       r->connection->ap_auth_type = "Basic";
-                       SG(request_info).auth_user = estrdup(tmp_user);
-               }
-               SG(request_info).auth_password = NULL;
-               if (tmp) {
-                       SG(request_info).auth_password = estrdup(tmp);
+               && (!PG(safe_mode) || (PG(safe_mode) && !auth_type(r)))) {
+               if (!strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
+                       tmp = uudecode(r->pool, authorization);
+                       tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
+                       if (tmp_user) {
+                               r->connection->user = pstrdup(r->connection->pool, tmp_user);
+                               r->connection->ap_auth_type = "Basic";
+                               SG(request_info).auth_user = estrdup(tmp_user);
+                       }
+                       if (tmp) {
+                               SG(request_info).auth_password = estrdup(tmp);
+                       }
+               } else if  (!strcasecmp(getword(r->pool, &authorization, ' '), "Digest")) {
+            r->connection->ap_auth_type = "Digest";
+            SG(request_info).auth_digest = estrdup(authorization);
                }
-       } else {
-               SG(request_info).auth_user = NULL;
-               SG(request_info).auth_password = NULL;
        }
 }
 /* }}} */
index aafed496cd9f9e210985181830402fb6d4974199..93334f67c6aee50d5cd38707d8be0d2ffa8167e4 100644 (file)
@@ -579,24 +579,26 @@ static void init_request_info(TSRMLS_D)
        if (r->headers_in) {
                authorization = table_get(r->headers_in, "Authorization");
        }
-       if (authorization
-               && !auth_type(r)
-               && !strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
-               tmp = uudecode(r->pool, authorization);
-               SG(request_info).auth_user = NULL;
-               tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
-               if (tmp_user) {
-                       r->connection->user = pstrdup(r->connection->pool, tmp_user);
-                       r->connection->ap_auth_type = "Basic";
-                       SG(request_info).auth_user = estrdup(tmp_user);
-               }
-               SG(request_info).auth_password = NULL;
-               if (tmp) {
-                       SG(request_info).auth_password = estrdup(tmp);
+
+       SG(request_info).auth_user = NULL;
+       SG(request_info).auth_password = NULL;
+
+       if (authorization && !auth_type(r)) {
+        if (!strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
+            tmp = uudecode(r->pool, authorization);
+            tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
+            if (tmp_user) {
+                r->connection->user = pstrdup(r->connection->pool, tmp_user);
+                r->connection->ap_auth_type = "Basic";
+                SG(request_info).auth_user = estrdup(tmp_user);
+            }
+            if (tmp) {
+                SG(request_info).auth_password = estrdup(tmp);
+            }
+               } else if  (!strcasecmp(getword(r->pool, &authorization, ' '), "Digest")) {
+            r->connection->ap_auth_type = "Digest";
+            SG(request_info).auth_digest = estrdup(authorization);
                }
-       } else {
-               SG(request_info).auth_user = NULL;
-               SG(request_info).auth_password = NULL;
        }
 }
 /* }}} */