You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by iv...@apache.org on 2011/02/12 14:07:13 UTC

svn commit: r1070074 - in /subversion/trunk/subversion/libsvn_ra_serf: auth.c auth_digest.c auth_digest.h auth_kerb.c auth_kerb.h fake_sspi.h ra_serf.h serf.c update.c util.c win32_auth_sspi.c win32_auth_sspi.h

Author: ivan
Date: Sat Feb 12 13:07:12 2011
New Revision: 1070074

URL: http://svn.apache.org/viewvc?rev=1070074&view=rev
Log:
Remove authentication code from ra_serf, since serf >= 0.7.0 already has 
basic, digest and negotiate (Kerberos+NTLM) authentication protocol 
implementation.

* subversion/libsvn_ra_serf/auth.c
* subversion/libsvn_ra_serf/auth_digest.c
* subversion/libsvn_ra_serf/auth_digest.h
* subversion/libsvn_ra_serf/auth_kerb.c
* subversion/libsvn_ra_serf/auth_kerb.h
* subversion/libsvn_ra_serf/fake_sspi.h
* subversion/libsvn_ra_serf/win32_auth_sspi.c
* subversion/libsvn_ra_serf/win32_auth_sspi.h
  (): Remove.

* subversion/libsvn_ra_serf/ra_serf.h
  (svn_ra_serf__auth_protocol_t, svn_serf__auth_handler_func_t,
   svn_serf__init_conn_func_t, svn_serf__setup_request_func_t,
   svn_serf__validate_response_func_t, svn_ra_serf__auth_protocol_t,
   svn_ra_serf__handle_auth, svn_ra_serf__encode_auth_header): Remove.
  (svn_ra_serf__connection_t, svn_ra_serf__session_t): Clean up unused 
   fields.

* subversion/libsvn_ra_serf/serf.c
  (svn_ra_serf__open): Do not initialize unused fields.

* subversion/libsvn_ra_serf/update.c
  (open_connection_if_needed): Do not initialize unused fields. Remove
   authentication protocol specific initialization.

* subversion/libsvn_ra_serf/util.c
  (connection_closed, svn_ra_serf__setup_serf_req): Remove authentication 
   protocol specific initialization.
  (handle_response): Remove authentication specific response handling
   -- serf will do this for us.

Removed:
    subversion/trunk/subversion/libsvn_ra_serf/auth.c
    subversion/trunk/subversion/libsvn_ra_serf/auth_digest.c
    subversion/trunk/subversion/libsvn_ra_serf/auth_digest.h
    subversion/trunk/subversion/libsvn_ra_serf/auth_kerb.c
    subversion/trunk/subversion/libsvn_ra_serf/auth_kerb.h
    subversion/trunk/subversion/libsvn_ra_serf/fake_sspi.h
    subversion/trunk/subversion/libsvn_ra_serf/win32_auth_sspi.c
    subversion/trunk/subversion/libsvn_ra_serf/win32_auth_sspi.h
Modified:
    subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
    subversion/trunk/subversion/libsvn_ra_serf/serf.c
    subversion/trunk/subversion/libsvn_ra_serf/update.c
    subversion/trunk/subversion/libsvn_ra_serf/util.c

Modified: subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h?rev=1070074&r1=1070073&r2=1070074&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Sat Feb 12 13:07:12 2011
@@ -59,14 +59,9 @@ extern "C" {
                    APR_STRINGIFY(SERF_MINOR_VERSION) "." \
                    APR_STRINGIFY(SERF_PATCH_VERSION)
 
-#ifdef WIN32
-#define SVN_RA_SERF_SSPI_ENABLED
-#endif
-
 
 /* Forward declarations. */
 typedef struct svn_ra_serf__session_t svn_ra_serf__session_t;
-typedef struct svn_ra_serf__auth_protocol_t svn_ra_serf__auth_protocol_t;
 
 typedef enum svn_ra_serf__authn_types
 {
@@ -101,12 +96,6 @@ typedef struct svn_ra_serf__connection_t
   /* What was the last HTTP status code we got on this connection? */
   int last_status_code;
 
-  /* Current authorization header used for this connection; may be NULL */
-  const char *auth_header;
-
-  /* Current authorization value used for this connection; may be NULL */
-  const char *auth_value;
-
   /* Optional SSL context for this connection. */
   serf_ssl_context_t *ssl_context;
   svn_auth_iterstate_t *ssl_client_auth_state;
@@ -114,18 +103,6 @@ typedef struct svn_ra_serf__connection_t
 
   svn_ra_serf__session_t *session;
 
-  /* Baton used to store connection specific authn/authz data */
-  void *auth_context;
-
-  /* Baton used to store proxy specific authn/authz data */
-  void *proxy_auth_context;
-
-  /* Current authorization header used for the proxy server; may be NULL */
-  const char *proxy_auth_header;
-
-  /* Current authorization value used for the proxy server; may be NULL */
-  const char *proxy_auth_value;
-
   /* user agent string */
   const char *useragent;
 
@@ -172,9 +149,6 @@ struct svn_ra_serf__session_t {
   apr_hash_t *cached_props;
 
   /* Authentication related properties. */
-  const char *realm;
-  const char *auth_header;
-  const char *auth_value;
   svn_auth_iterstate_t *auth_state;
   int auth_attempts;
 
@@ -189,9 +163,6 @@ struct svn_ra_serf__session_t {
   /* Error that we've received but not yet returned upstream. */
   svn_error_t *pending_error;
 
-  /* vtable and info object handling the authentication */
-  const svn_ra_serf__auth_protocol_t *auth_protocol;
-
   /* List of authn types supported by the client.*/
   svn_ra_serf__authn_types authn_types;
 
@@ -207,11 +178,6 @@ struct svn_ra_serf__session_t {
   /* Are we using a proxy? */
   int using_proxy;
 
-  /* Proxy Authentication related properties */
-  const char *proxy_auth_header;
-  const char *proxy_auth_value;
-  const svn_ra_serf__auth_protocol_t *proxy_auth_protocol;
-
   const char *proxy_username;
   const char *proxy_password;
   int proxy_auth_attempts;
@@ -1444,105 +1410,6 @@ svn_ra_serf__credentials_callback(char *
                                   int code, const char *authn_type,
                                   const char *realm,
                                   apr_pool_t *pool);
-/**
- * For each authentication protocol we need a handler function of type
- * svn_serf__auth_handler_func_t. This function will be called when an
- * authentication challenge is received in a session.
- */
-typedef svn_error_t *
-(*svn_serf__auth_handler_func_t)(svn_ra_serf__handler_t *ctx,
-                                 serf_request_t *request,
-                                 serf_bucket_t *response,
-                                 const char *auth_hdr,
-                                 const char *auth_attr,
-                                 apr_pool_t *pool);
-
-/**
- * For each authentication protocol we need an initialization function of type
- * svn_serf__init_conn_func_t. This function will be called when a new
- * connection is opened.
- */
-typedef svn_error_t *
-(*svn_serf__init_conn_func_t)(svn_ra_serf__session_t *session,
-                              svn_ra_serf__connection_t *conn,
-                              apr_pool_t *pool);
-
-/**
- * For each authentication protocol we need a setup_request function of type
- * svn_serf__setup_request_func_t. This function will be called when a
- * new serf_request_t object is created and should fill in the correct
- * authentication headers (if needed).
- */
-typedef svn_error_t *
-(*svn_serf__setup_request_func_t)(svn_ra_serf__connection_t *conn,
-                                  const char *method,
-                                  const char *uri,
-                                  serf_bucket_t *hdrs_bkt);
-
-/**
- * This function will be called when a response is received, so that the
- * protocol handler can validate the Authentication related response headers
- * (if needed).
- */
-typedef svn_error_t *
-(*svn_serf__validate_response_func_t)(svn_ra_serf__handler_t *ctx,
-                                      serf_request_t *request,
-                                      serf_bucket_t *response,
-                                      apr_pool_t *pool);
-
-/**
- * svn_ra_serf__auth_protocol_t: vtable for an authn protocol provider.
- *
- */
-struct svn_ra_serf__auth_protocol_t {
-  /* The http status code that's handled by this authentication protocol.
-     Normal values are 401 for server authentication and 407 for proxy
-     authentication */
-  int code;
-
-  /* The name of this authentication protocol. This should be a case
-     sensitive match of the string sent in the HTTP authentication header. */
-  const char *auth_name;
-
-  /* Internal code used for this authn type. */
-  svn_ra_serf__authn_types auth_type;
-
-  /* The initialization function if any; otherwise, NULL */
-  svn_serf__init_conn_func_t init_conn_func;
-
-  /* The authentication handler function */
-  svn_serf__auth_handler_func_t handle_func;
-
-  /* Function to set up the authentication header of a request */
-  svn_serf__setup_request_func_t setup_request_func;
-
-  /* Function to validate the authentication header of a response */
-  svn_serf__validate_response_func_t validate_response_func;
-};
-
-/**
- * This function will be called when an authentication challenge is
- * received. Based on the challenge, handle_auth will pick the needed
- * authn implementation and forward the call to its authn handler.
- */
-svn_error_t *
-svn_ra_serf__handle_auth(int code,
-                         svn_ra_serf__handler_t *ctx,
-                         serf_request_t *request,
-                         serf_bucket_t *response,
-                         apr_pool_t *pool);
-
-/**
- * encode_auth_header: base64 encodes the authentication data and builds an
- * authentication header in this format:
- * [PROTOCOL] [BASE64 AUTH DATA]
- */
-void
-svn_ra_serf__encode_auth_header(const char *protocol,
-                                const char **header,
-                                const char *data,
-                                apr_size_t data_len,
-                                apr_pool_t *pool);
 
 
 /*** General utility functions ***/

Modified: subversion/trunk/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/serf.c?rev=1070074&r1=1070073&r2=1070074&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/serf.c Sat Feb 12 13:07:12 2011
@@ -422,8 +422,6 @@ svn_ra_serf__open(svn_ra_session_t *sess
   serf_sess->conns[0]->using_ssl = serf_sess->using_ssl;
   serf_sess->conns[0]->using_compression = serf_sess->using_compression;
   serf_sess->conns[0]->hostinfo = url.hostinfo;
-  serf_sess->conns[0]->auth_header = NULL;
-  serf_sess->conns[0]->auth_value = NULL;
   serf_sess->conns[0]->useragent = NULL;
 
   /* create the user agent string */

Modified: subversion/trunk/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/update.c?rev=1070074&r1=1070073&r2=1070074&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/update.c Sat Feb 12 13:07:12 2011
@@ -2198,8 +2198,6 @@ open_connection_if_needed(svn_ra_serf__s
       sess->conns[cur]->hostinfo = sess->conns[0]->hostinfo;
       sess->conns[cur]->using_ssl = sess->conns[0]->using_ssl;
       sess->conns[cur]->using_compression = sess->conns[0]->using_compression;
-      sess->conns[cur]->proxy_auth_header = sess->conns[0]->proxy_auth_header;
-      sess->conns[cur]->proxy_auth_value = sess->conns[0]->proxy_auth_value;
       sess->conns[cur]->useragent = sess->conns[0]->useragent;
       sess->conns[cur]->last_status_code = -1;
       sess->conns[cur]->ssl_context = NULL;
@@ -2216,15 +2214,6 @@ open_connection_if_needed(svn_ra_serf__s
         return svn_error_wrap_apr(status, NULL);
 
       sess->num_conns++;
-
-      /* Authentication protocol specific initalization. */
-      if (sess->auth_protocol)
-        SVN_ERR(sess->auth_protocol->init_conn_func(sess, sess->conns[cur],
-                                                    sess->pool));
-      if (sess->proxy_auth_protocol)
-        SVN_ERR(sess->proxy_auth_protocol->init_conn_func(sess,
-                                                          sess->conns[cur],
-                                                          sess->pool));
     }
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1070074&r1=1070073&r2=1070074&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Sat Feb 12 13:07:12 2011
@@ -404,12 +404,6 @@ connection_closed(serf_connection_t *con
   if (sc->using_ssl)
       sc->ssl_context = NULL;
 
-  /* Restart the authentication phase on this new connection. */
-  if (sc->session->auth_protocol)
-    SVN_ERR(sc->session->auth_protocol->init_conn_func(sc->session,
-                                                       sc,
-                                                       sc->session->pool));
-
   return SVN_NO_ERROR;
 }
 
@@ -598,18 +592,6 @@ svn_ra_serf__setup_serf_req(serf_request
   serf_bucket_headers_set(hdrs_bkt, "DAV", SVN_DAV_NS_DAV_SVN_MERGEINFO);
   serf_bucket_headers_set(hdrs_bkt, "DAV", SVN_DAV_NS_DAV_SVN_LOG_REVPROPS);
 
-  /* Setup server authorization headers */
-  if (conn->session->auth_protocol)
-    SVN_ERR(conn->session->auth_protocol->setup_request_func(conn, method, url,
-                                                             hdrs_bkt));
-
-  /* Setup proxy authorization headers */
-  if (conn->session->proxy_auth_protocol)
-    SVN_ERR(conn->session->proxy_auth_protocol->setup_request_func(conn,
-                                                                   method,
-                                                                   url,
-                                                                   hdrs_bkt));
-
   if (ret_hdrs_bkt)
     {
       *ret_hdrs_bkt = hdrs_bkt;
@@ -1467,34 +1449,11 @@ handle_response(serf_request_t *request,
                                         ctx->session->pool));
       ctx->session->auth_attempts = 0;
       ctx->session->auth_state = NULL;
-      ctx->session->realm = NULL;
     }
 
   ctx->conn->last_status_code = sl.code;
 
-  if (sl.code == 401 || sl.code == 407)
-    {
-      /* 401 Authorization or 407 Proxy-Authentication required */
-      status = svn_ra_serf__response_discard_handler(request, response, NULL, pool);
-
-      /* Don't bother handling the authentication request if the response
-         wasn't received completely yet. Serf will call handle_response
-         again when more data is received. */
-      if (APR_STATUS_IS_EAGAIN(status))
-        {
-          *serf_status = status;
-          return SVN_NO_ERROR;
-        }
-
-      SVN_ERR(svn_ra_serf__handle_auth(sl.code, ctx,
-                                       request, response, pool));
-
-      svn_ra_serf__priority_request_create(ctx);
-
-      *serf_status = status;
-      return SVN_NO_ERROR;
-    }
-  else if (sl.code == 409 || sl.code >= 500)
+  if (sl.code == 409 || sl.code >= 500)
     {
       /* 409 Conflict: can indicate a hook error.
          5xx (Internal) Server error. */
@@ -1513,28 +1472,6 @@ handle_response(serf_request_t *request,
     {
       svn_error_t *err;
 
-      /* Validate this response message. */
-      if (ctx->session->auth_protocol ||
-          ctx->session->proxy_auth_protocol)
-        {
-          const svn_ra_serf__auth_protocol_t *prot;
-
-          if (ctx->session->auth_protocol)
-            prot = ctx->session->auth_protocol;
-          else
-            prot = ctx->session->proxy_auth_protocol;
-
-          err = prot->validate_response_func(ctx, request, response, pool);
-          if (err)
-            {
-              svn_ra_serf__response_discard_handler(request, response, NULL,
-                                                    pool);
-              /* Ignore serf status code, just return the real error */
-
-              return svn_error_return(err);
-            }
-        }
-
       err = ctx->response_handler(request,response, ctx->response_baton, pool);
 
       if (err