You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by lg...@apache.org on 2009/12/27 11:57:41 UTC
svn commit: r894053 - in /subversion/trunk/subversion/libsvn_ra_serf: auth.c
ra_serf.h serf.c util.c
Author: lgo
Date: Sun Dec 27 10:57:39 2009
New Revision: 894053
URL: http://svn.apache.org/viewvc?rev=894053&view=rev
Log:
ra_serf: Use the new serf API for serf-based authentication. Remove support for
Basic authentication, as serf will handle that now.
Requires serf r1289 (when building svn with serf trunk).
* subversion/libsvn_ra_serf/ra_serf.h
(svn_ra_serf__credentials_callback): New declaration.
* subversion/libsvn_ra_serf/serf.c
(load_config): Load list of enabled authentication types. Define credentials
callback for serf. TODO: define enabled authn types for serf.
* subversion/libsvn_ra_serf/auth.c
(serf_auth_protocols): Disable Basic authentication in ra_serf as serf will
handle it now.
* subversion/libsvn_ra_serf/util.c
(svn_ra_serf__credentials_callback): New function, provides credentials for
Basic and Digest authentication to serf.
Modified:
subversion/trunk/subversion/libsvn_ra_serf/auth.c
subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
subversion/trunk/subversion/libsvn_ra_serf/serf.c
subversion/trunk/subversion/libsvn_ra_serf/util.c
Modified: subversion/trunk/subversion/libsvn_ra_serf/auth.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/auth.c?rev=894053&r1=894052&r2=894053&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/auth.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/auth.c Sun Dec 27 10:57:39 2009
@@ -33,6 +33,7 @@
/*** Forward declarations. ***/
+#if ! SERF_VERSION_AT_LEAST(0, 4, 0)
static svn_error_t *
handle_basic_auth(svn_ra_serf__handler_t *ctx,
serf_request_t *request,
@@ -51,6 +52,7 @@
const char *method,
const char *uri,
serf_bucket_t *hdrs_bkt);
+#endif
static svn_error_t *
handle_proxy_basic_auth(svn_ra_serf__handler_t *ctx,
@@ -82,6 +84,8 @@
/*** Global variables. ***/
static const svn_ra_serf__auth_protocol_t serf_auth_protocols[] = {
+#if ! SERF_VERSION_AT_LEAST(0, 4, 0)
+ /* serf handles Basic authentication. */
{
401,
"Basic",
@@ -91,6 +95,7 @@
setup_request_basic_auth,
default_auth_response_handler,
},
+#endif
{
407,
"Basic",
@@ -356,6 +361,7 @@
return SVN_NO_ERROR;
}
+#if ! SERF_VERSION_AT_LEAST(0, 4, 0)
static svn_error_t *
handle_basic_auth(svn_ra_serf__handler_t *ctx,
serf_request_t *request,
@@ -496,6 +502,7 @@
return SVN_NO_ERROR;
}
+#endif
static svn_error_t *
handle_proxy_basic_auth(svn_ra_serf__handler_t *ctx,
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=894053&r1=894052&r2=894053&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Sun Dec 27 10:57:39 2009
@@ -1402,6 +1402,16 @@
/*** Authentication handler declarations ***/
/**
+ * Callback function that loads the credentials for Basic and Digest
+ * authentications, both for server and proxy authentication.
+ */
+apr_status_t
+svn_ra_serf__credentials_callback(char **username, char **password,
+ serf_request_t *request, void *baton,
+ 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.
Modified: subversion/trunk/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/serf.c?rev=894053&r1=894052&r2=894053&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/serf.c Sun Dec 27 10:57:39 2009
@@ -303,9 +303,13 @@
else
session->using_proxy = FALSE;
- /* Load the list of support authn types. */
- SVN_ERR(load_http_auth_types(pool, config, server_group,
- &session->authn_types));
+ /* Setup authentication. */
+ SVN_ERR(load_http_auth_types(pool, config, server_group,
+ &session->authn_types));
+ /* TODO: convert string authn types to SERF_AUTHN bitmask.
+ serf_config_authn_types(session->context, session->authn_types);*/
+ serf_config_credentials_callback(session->context,
+ svn_ra_serf__credentials_callback);
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=894053&r1=894052&r2=894053&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Sun Dec 27 10:57:39 2009
@@ -1171,6 +1171,74 @@
return server_err.error;
}
+apr_status_t
+svn_ra_serf__credentials_callback(char **username, char **password,
+ serf_request_t *request, void *baton,
+ int code, const char *authn_type,
+ const char *realm,
+ apr_pool_t *pool)
+{
+ svn_ra_serf__handler_t *ctx = baton;
+ svn_ra_serf__session_t *session = ctx->session;
+ void *creds;
+ svn_auth_cred_simple_t *simple_creds;
+ svn_error_t *err;
+
+ if (code == 401)
+ {
+ /* Use svn_auth_first_credentials if this is the first time we ask for
+ credentials during this session OR if the last time we asked
+ session->auth_state wasn't set (eg. if the credentials provider was
+ cancelled by the user). */
+ if (!session->auth_state)
+ {
+ err = svn_auth_first_credentials(&creds,
+ &session->auth_state,
+ SVN_AUTH_CRED_SIMPLE,
+ realm,
+ session->wc_callbacks->auth_baton,
+ session->pool);
+ }
+ else
+ {
+ err = svn_auth_next_credentials(&creds,
+ session->auth_state,
+ session->pool);
+ }
+
+ if (err)
+ {
+ ctx->session->pending_error = err;
+ return err->apr_err;
+ }
+
+ session->auth_attempts++;
+
+ if (!creds || session->auth_attempts > 4)
+ {
+ /* No more credentials. */
+ ctx->session->pending_error =
+ svn_error_create(SVN_ERR_AUTHN_FAILED, NULL,
+ "No more credentials or we tried too many times.\n"
+ "Authentication failed");
+ return SVN_ERR_AUTHN_FAILED;
+ }
+
+ simple_creds = creds;
+ *username = apr_pstrdup(pool, simple_creds->username);
+ *password = apr_pstrdup(pool, simple_creds->password);
+ }
+ else
+ {
+ *username = apr_pstrdup(pool, session->proxy_username);
+ *password = apr_pstrdup(pool, session->proxy_password);
+ }
+
+ ctx->conn->last_status_code = code;
+
+ return APR_SUCCESS;
+}
+
/* Implements the serf_response_handler_t interface. Wait for HTTP
response status and headers, and invoke CTX->response_handler() to
carry out operation-specific processing. Afterwards, check for
Re: svn commit: r894053 - in /subversion/trunk/subversion/libsvn_ra_serf:
auth.c ra_serf.h serf.c util.c
Posted by Lieven Govaerts <sv...@mobsol.be>.
On Mon, Dec 28, 2009 at 11:40 PM, Hyrum K. Wright
<hy...@mail.utexas.edu> wrote:
>
> On Dec 27, 2009, at 4:57 AM, lgo@apache.org wrote:
>
>> Author: lgo
>> Date: Sun Dec 27 10:57:39 2009
>> New Revision: 894053
>>
>> URL: http://svn.apache.org/viewvc?rev=894053&view=rev
>> Log:
>> ra_serf: Use the new serf API for serf-based authentication. Remove support for
>> Basic authentication, as serf will handle that now.
>>
>> Requires serf r1289 (when building svn with serf trunk).
>
> This looks like Subversion trunk should be still buildable with serf 0.3, but when I try to do that, I get the following error:
>
> [[[
> dhcp-198-227:svn-trunk Hyrum$ make -j1
> cd subversion/svn && /opt/local/share/apr-1/build/libtool --tag=CC --silent --mode=link gcc -static -Wold-style-definition -Wshorten-64-to-32 -Wnewline-eof -Wextra-tokens -Wdeclaration-after-statement -Wpointer-arith -Wwrite-strings -Wshadow -ansi -Wall -Wformat=2 -Wunused -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wno-multichar -Wredundant-decls -Wnested-externs -Wunreachable-code -Winline -Wno-long-long -g -Werror=implicit-function-declaration -DSVN_DEBUG -DAP_DEBUG -L/opt/local/lib/db46 -L/opt/local/lib -rpath /usr/local/lib -o svn add-cmd.lo blame-cmd.lo cat-cmd.lo changelist-cmd.lo checkout-cmd.lo cleanup-cmd.lo commit-cmd.lo conflict-callbacks.lo copy-cmd.lo delete-cmd.lo diff-cmd.lo export-cmd.lo help-cmd.lo import-cmd.lo info-cmd.lo list-cmd.lo lock-cmd.lo log-cmd.lo main.lo merge-cmd.lo mergeinfo-cmd.lo mkdir-cmd.lo move-cmd.lo notify.lo obliterate-cmd.lo patch-cmd.lo propdel-cmd.lo propedit-cmd.lo propget-cmd.lo proplist-cmd.lo props.lo propset-cmd.lo resolve-cmd.lo resolved-cmd.lo revert-cmd.lo status-cmd.lo status.lo switch-cmd.lo tree-conflicts.lo unlock-cmd.lo update-cmd.lo upgrade-cmd.lo util.lo ../../subversion/libsvn_client/libsvn_client-1.la ../../subversion/libsvn_wc/libsvn_wc-1.la ../../subversion/libsvn_ra/libsvn_ra-1.la ../../subversion/libsvn_delta/libsvn_delta-1.la ../../subversion/libsvn_diff/libsvn_diff-1.la ../../subversion/libsvn_subr/libsvn_subr-1.la -L/opt/local/lib -laprutil-1 -L/opt/local/lib -lapr-1 -lintl -framework Security -framework CoreFoundation -framework CoreServices
> Undefined symbols:
> "_serf_config_credentials_callback", referenced from:
> _load_config in libsvn_ra_serf-1.a(serf.o)
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> make: *** [subversion/svn/svn] Error 1
> ]]]
>
> Do I need serf trunk to build Subversion trunk now?
No, serf 0.3 should work fine. Fixed this issue in r894320.
thanks,
Lieven
Re: svn commit: r894053 - in /subversion/trunk/subversion/libsvn_ra_serf: auth.c ra_serf.h serf.c util.c
Posted by "Hyrum K. Wright" <hy...@mail.utexas.edu>.
On Dec 27, 2009, at 4:57 AM, lgo@apache.org wrote:
> Author: lgo
> Date: Sun Dec 27 10:57:39 2009
> New Revision: 894053
>
> URL: http://svn.apache.org/viewvc?rev=894053&view=rev
> Log:
> ra_serf: Use the new serf API for serf-based authentication. Remove support for
> Basic authentication, as serf will handle that now.
>
> Requires serf r1289 (when building svn with serf trunk).
This looks like Subversion trunk should be still buildable with serf 0.3, but when I try to do that, I get the following error:
[[[
dhcp-198-227:svn-trunk Hyrum$ make -j1
cd subversion/svn && /opt/local/share/apr-1/build/libtool --tag=CC --silent --mode=link gcc -static -Wold-style-definition -Wshorten-64-to-32 -Wnewline-eof -Wextra-tokens -Wdeclaration-after-statement -Wpointer-arith -Wwrite-strings -Wshadow -ansi -Wall -Wformat=2 -Wunused -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wno-multichar -Wredundant-decls -Wnested-externs -Wunreachable-code -Winline -Wno-long-long -g -Werror=implicit-function-declaration -DSVN_DEBUG -DAP_DEBUG -L/opt/local/lib/db46 -L/opt/local/lib -rpath /usr/local/lib -o svn add-cmd.lo blame-cmd.lo cat-cmd.lo changelist-cmd.lo checkout-cmd.lo cleanup-cmd.lo commit-cmd.lo conflict-callbacks.lo copy-cmd.lo delete-cmd.lo diff-cmd.lo export-cmd.lo help-cmd.lo import-cmd.lo info-cmd.lo list-cmd.lo lock-cmd.lo log-cmd.lo main.lo merge-cmd.lo mergeinfo-cmd.lo mkdir-cmd.lo move-cmd.lo notify.lo obliterate-cmd.lo patch-cmd.lo propdel-cmd.lo propedit-cmd.lo propget-cmd.lo proplist-cmd.lo props.lo propset-cmd.lo resolve-cmd.lo resolved-cmd.lo revert-cmd.lo status-cmd.lo status.lo switch-cmd.lo tree-conflicts.lo unlock-cmd.lo update-cmd.lo upgrade-cmd.lo util.lo ../../subversion/libsvn_client/libsvn_client-1.la ../../subversion/libsvn_wc/libsvn_wc-1.la ../../subversion/libsvn_ra/libsvn_ra-1.la ../../subversion/libsvn_delta/libsvn_delta-1.la ../../subversion/libsvn_diff/libsvn_diff-1.la ../../subversion/libsvn_subr/libsvn_subr-1.la -L/opt/local/lib -laprutil-1 -L/opt/local/lib -lapr-1 -lintl -framework Security -framework CoreFoundation -framework CoreServices
Undefined symbols:
"_serf_config_credentials_callback", referenced from:
_load_config in libsvn_ra_serf-1.a(serf.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [subversion/svn/svn] Error 1
]]]
Do I need serf trunk to build Subversion trunk now?
-Hyrum