svn_auth.h

Go to the documentation of this file.
00001 /**
00002  * @copyright
00003  * ====================================================================
00004  * Copyright (c) 2002-2008 CollabNet.  All rights reserved.
00005  *
00006  * This software is licensed as described in the file COPYING, which
00007  * you should have received as part of this distribution.  The terms
00008  * are also available at http://subversion.tigris.org/license-1.html.
00009  * If newer versions of this license are posted there, you may use a
00010  * newer version instead, at your option.
00011  *
00012  * This software consists of voluntary contributions made by many
00013  * individuals.  For exact contribution history, see the revision
00014  * history and logs, available at http://subversion.tigris.org/.
00015  * ====================================================================
00016  * @endcopyright
00017  *
00018  * @file svn_auth.h
00019  * @brief Subversion's authentication system
00020  */
00021 
00022 #ifndef SVN_AUTH_H
00023 #define SVN_AUTH_H
00024 
00025 #include <apr_pools.h>
00026 
00027 #include "svn_types.h"
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif /* __cplusplus */
00032 
00033 /** Overview of the svn authentication system.
00034  *
00035  * We define an authentication "provider" as a module that is able to
00036  * return a specific set of credentials. (e.g. username/password,
00037  * certificate, etc.)  Each provider implements a vtable that
00038  *
00039  * - can fetch initial credentials
00040  * - can retry the fetch (or try to fetch something different)
00041  * - can store the credentials for future use
00042  *
00043  * For any given type of credentials, there can exist any number of
00044  * separate providers -- each provider has a different method of
00045  * fetching. (i.e. from a disk store, by prompting the user, etc.)
00046  *
00047  * The application begins by creating an auth baton object, and
00048  * "registers" some number of providers with the auth baton, in a
00049  * specific order.  (For example, it may first register a
00050  * username/password provider that looks in disk store, then register
00051  * a username/password provider that prompts the user.)
00052  *
00053  * Later on, when any svn library is challenged, it asks the auth
00054  * baton for the specific credentials.  If the initial credentials
00055  * fail to authenticate, the caller keeps requesting new credentials.
00056  * Under the hood, libsvn_auth effectively "walks" over each provider
00057  * (in order of registry), one at a time, until all the providers have
00058  * exhausted all their retry options.
00059  *
00060  * This system allows an application to flexibly define authentication
00061  * behaviors (by changing registration order), and very easily write
00062  * new authentication providers.
00063  *
00064  * An auth_baton also contains an internal hashtable of run-time
00065  * parameters; any provider or library layer can set these run-time
00066  * parameters at any time, so that the provider has access to the
00067  * data.  (For example, certain run-time data may not be available
00068  * until an authentication challenge is made.)  Each credential type
00069  * must document the run-time parameters that are made available to
00070  * its providers.
00071  *
00072  * @defgroup auth_fns Authentication functions
00073  * @{
00074  */
00075 
00076 
00077 /** The type of a Subversion authentication object */
00078 typedef struct svn_auth_baton_t svn_auth_baton_t;
00079 
00080 /** The type of a Subversion authentication-iteration object */
00081 typedef struct svn_auth_iterstate_t svn_auth_iterstate_t;
00082 
00083 
00084 /** The main authentication "provider" vtable. */
00085 typedef struct svn_auth_provider_t
00086 {
00087   /** The kind of credentials this provider knows how to retrieve. */
00088   const char *cred_kind;
00089 
00090   /** Get an initial set of credentials.
00091    *
00092    * Set @a *credentials to a set of valid credentials within @a
00093    * realmstring, or NULL if no credentials are available.  Set @a
00094    * *iter_baton to context that allows a subsequent call to @c
00095    * next_credentials, in case the first credentials fail to
00096    * authenticate.  @a provider_baton is general context for the
00097    * vtable, @a parameters contains any run-time data that the
00098    * provider may need, and @a realmstring comes from the
00099    * svn_auth_first_credentials() call.
00100    */
00101   svn_error_t * (*first_credentials)(void **credentials,
00102                                      void **iter_baton,
00103                                      void *provider_baton,
00104                                      apr_hash_t *parameters,
00105                                      const char *realmstring,
00106                                      apr_pool_t *pool);
00107 
00108   /** Get a different set of credentials.
00109    *
00110    * Set @a *credentials to another set of valid credentials (using @a
00111    * iter_baton as the context from previous call to first_credentials
00112    * or next_credentials).  If no more credentials are available, set
00113    * @a *credentials to NULL.  If the provider only has one set of
00114    * credentials, this function pointer should simply be NULL. @a
00115    * provider_baton is general context for the vtable, @a parameters
00116    * contains any run-time data that the provider may need, and @a
00117    * realmstring comes from the svn_auth_first_credentials() call.
00118    */
00119   svn_error_t * (*next_credentials)(void **credentials,
00120                                     void *iter_baton,
00121                                     void *provider_baton,
00122                                     apr_hash_t *parameters,
00123                                     const char *realmstring,
00124                                     apr_pool_t *pool);
00125 
00126   /** Save credentials.
00127    *
00128    * Store @a credentials for future use.  @a provider_baton is
00129    * general context for the vtable, and @a parameters contains any
00130    * run-time data the provider may need.  Set @a *saved to TRUE if
00131    * the save happened, or FALSE if not.  The provider is not required
00132    * to save; if it refuses or is unable to save for non-fatal
00133    * reasons, return FALSE.  If the provider never saves data, then
00134    * this function pointer should simply be NULL. @a realmstring comes
00135    * from the svn_auth_first_credentials() call.
00136    *
00137    * All allocations should be done in @a pool, which can be assumed
00138    * to survive across RA sessions; auth providers that store passwords
00139    * in plaintext rely on this.
00140    */
00141   svn_error_t * (*save_credentials)(svn_boolean_t *saved,
00142                                     void *credentials,
00143                                     void *provider_baton,
00144                                     apr_hash_t *parameters,
00145                                     const char *realmstring,
00146                                     apr_pool_t *pool);
00147 
00148 } svn_auth_provider_t;
00149 
00150 
00151 /** A provider object, ready to be put into an array and given to
00152     svn_auth_open(). */
00153 typedef struct svn_auth_provider_object_t
00154 {
00155   const svn_auth_provider_t *vtable;
00156   void *provider_baton;
00157 
00158 } svn_auth_provider_object_t;
00159 
00160 /** The type of function returning authentication provider. */
00161 typedef void (*svn_auth_simple_provider_func_t)
00162   (svn_auth_provider_object_t **provider,
00163    apr_pool_t *pool);
00164 
00165 
00166 /** Specific types of credentials **/
00167 
00168 /** Simple username/password pair credential kind.
00169  *
00170  * The following auth parameters may be available to the providers:
00171  *
00172  * - @c SVN_AUTH_PARAM_NO_AUTH_CACHE (@c void*)
00173  * - @c SVN_AUTH_PARAM_DEFAULT_USERNAME (@c char*)
00174  * - @c SVN_AUTH_PARAM_DEFAULT_PASSWORD (@c char*)
00175  */
00176 #define SVN_AUTH_CRED_SIMPLE "svn.simple"
00177 
00178 /** @c SVN_AUTH_CRED_SIMPLE credentials. */
00179 typedef struct svn_auth_cred_simple_t
00180 {
00181   /** Username */
00182   const char *username;
00183   /** Password */
00184   const char *password;
00185   /** Indicates if the credentials may be saved (to disk). For example, a
00186    * GUI prompt implementation with a remember password checkbox shall set
00187    * @a may_save to TRUE if the checkbox is checked.
00188    */
00189   svn_boolean_t may_save;
00190 } svn_auth_cred_simple_t;
00191 
00192 
00193 /** Username credential kind.
00194  *
00195  * The following optional auth parameters are relevant to the providers:
00196  *
00197  * - @c SVN_AUTH_PARAM_NO_AUTH_CACHE (@c void*)
00198  * - @c SVN_AUTH_PARAM_DEFAULT_USERNAME (@c char*)
00199  */
00200 #define SVN_AUTH_CRED_USERNAME "svn.username"
00201 
00202 /** @c SVN_AUTH_CRED_USERNAME credentials. */
00203 typedef struct svn_auth_cred_username_t
00204 {
00205   /** Username */
00206   const char *username;
00207   /** Indicates if the credentials may be saved (to disk). For example, a
00208    * GUI prompt implementation with a remember username checkbox shall set
00209    * @a may_save to TRUE if the checkbox is checked.
00210    */
00211   svn_boolean_t may_save;
00212 } svn_auth_cred_username_t;
00213 
00214 
00215 /** SSL client certificate credential type.
00216  *
00217  * The following auth parameters are available to the providers:
00218  *
00219  * - @c SVN_AUTH_PARAM_CONFIG (@c svn_config_t*)
00220  * - @c SVN_AUTH_PARAM_SERVER_GROUP (@c char*)
00221  *
00222  * The following optional auth parameters are relevant to the providers:
00223  *
00224  * - @c SVN_AUTH_PARAM_NO_AUTH_CACHE (@c void*)
00225  */
00226 #define SVN_AUTH_CRED_SSL_CLIENT_CERT "svn.ssl.client-cert"
00227 
00228 /** @c SVN_AUTH_CRED_SSL_CLIENT_CERT credentials. */
00229 typedef struct svn_auth_cred_ssl_client_cert_t
00230 {
00231   /** Absolute path to the certificate file */
00232   const char *cert_file;
00233   /** Indicates if the credentials may be saved (to disk). For example, a
00234    * GUI prompt implementation with a remember certificate checkbox shall
00235    * set @a may_save to TRUE if the checkbox is checked.
00236    */
00237   svn_boolean_t may_save;
00238 } svn_auth_cred_ssl_client_cert_t;
00239 
00240 
00241 /** A function returning an SSL client certificate passphrase provider. */
00242 typedef void (*svn_auth_ssl_client_cert_pw_provider_func_t)
00243   (svn_auth_provider_object_t **provider,
00244    apr_pool_t *pool);
00245 
00246 /** SSL client certificate passphrase credential type.
00247  *
00248  * @note The realmstring used with this credential type must be a name that
00249  * makes it possible for the user to identify the certificate.
00250  *
00251  * The following auth parameters are available to the providers:
00252  *
00253  * - @c SVN_AUTH_PARAM_CONFIG (@c svn_config_t*)
00254  * - @c SVN_AUTH_PARAM_SERVER_GROUP (@c char*)
00255  *
00256  * The following optional auth parameters are relevant to the providers:
00257  *
00258  * - @c SVN_AUTH_PARAM_NO_AUTH_CACHE (@c void*)
00259  */
00260 #define SVN_AUTH_CRED_SSL_CLIENT_CERT_PW "svn.ssl.client-passphrase"
00261 
00262 /** @c SVN_AUTH_CRED_SSL_CLIENT_CERT_PW credentials. */
00263 typedef struct svn_auth_cred_ssl_client_cert_pw_t
00264 {
00265   /** Certificate password */
00266   const char *password;
00267   /** Indicates if the credentials may be saved (to disk). For example, a
00268    * GUI prompt implementation with a remember password checkbox shall set
00269    * @a may_save to TRUE if the checkbox is checked.
00270    */
00271   svn_boolean_t may_save;
00272 } svn_auth_cred_ssl_client_cert_pw_t;
00273 
00274 
00275 /** SSL server verification credential type.
00276  *
00277  * The following auth parameters are available to the providers:
00278  *
00279  * - @c SVN_AUTH_PARAM_CONFIG (@c svn_config_t*)
00280  * - @c SVN_AUTH_PARAM_SERVER_GROUP (@c char*)
00281  * - @c SVN_AUTH_PARAM_SSL_SERVER_FAILURES (@c apr_uint32_t*)
00282  * - @c SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO
00283  *      (@c svn_auth_ssl_server_cert_info_t*)
00284  *
00285  * The following optional auth parameters are relevant to the providers:
00286  *
00287  * - @c SVN_AUTH_PARAM_NO_AUTH_CACHE (@c void*)
00288  */
00289 #define SVN_AUTH_CRED_SSL_SERVER_TRUST "svn.ssl.server"
00290 
00291 /** SSL server certificate information used by @c
00292  * SVN_AUTH_CRED_SSL_SERVER_TRUST providers.
00293  */
00294 typedef struct svn_auth_ssl_server_cert_info_t
00295 {
00296   /** Primary CN */
00297   const char *hostname;
00298   /** ASCII fingerprint */
00299   const char *fingerprint;
00300   /** ASCII date from which the certificate is valid */
00301   const char *valid_from;
00302   /** ASCII date until which the certificate is valid */
00303   const char *valid_until;
00304   /** DN of the certificate issuer */
00305   const char *issuer_dname;
00306   /** Base-64 encoded DER certificate representation */
00307   const char *ascii_cert;
00308 } svn_auth_ssl_server_cert_info_t;
00309 
00310 /**
00311  * Return a deep copy of @a info, allocated in @a pool.
00312  *
00313  * @since New in 1.3.
00314  */
00315 svn_auth_ssl_server_cert_info_t *
00316 svn_auth_ssl_server_cert_info_dup(const svn_auth_ssl_server_cert_info_t *info,
00317                                   apr_pool_t *pool);
00318 
00319 /** @c SVN_AUTH_CRED_SSL_SERVER_TRUST credentials. */
00320 typedef struct svn_auth_cred_ssl_server_trust_t
00321 {
00322   /** Indicates if the credentials may be saved (to disk). For example, a
00323    * GUI prompt implementation with a checkbox to accept the certificate
00324    * permanently shall set @a may_save to TRUE if the checkbox is checked.
00325    */
00326   svn_boolean_t may_save;
00327   /** Bit mask of the accepted failures */
00328   apr_uint32_t accepted_failures;
00329 } svn_auth_cred_ssl_server_trust_t;
00330 
00331 
00332 
00333 /** Credential-constructing prompt functions. **/
00334 
00335 /** These exist so that different client applications can use
00336  * different prompt mechanisms to supply the same credentials.  For
00337  * example, if authentication requires a username and password, a
00338  * command-line client's prompting function might prompt first for the
00339  * username and then for the password, whereas a GUI client's would
00340  * present a single dialog box asking for both, and a telepathic
00341  * client's would read all the information directly from the user's
00342  * mind.  All these prompting functions return the same type of
00343  * credential, but the information used to construct the credential is
00344  * gathered in an interface-specific way in each case.
00345  */
00346 
00347 /** Set @a *cred by prompting the user, allocating @a *cred in @a pool.
00348  * @a baton is an implementation-specific closure.
00349  *
00350  * If @a realm is non-NULL, maybe use it in the prompt string.
00351  *
00352  * If @a username is non-NULL, then the user might be prompted only
00353  * for a password, but @a *cred would still be filled with both
00354  * username and password.  For example, a typical usage would be to
00355  * pass @a username on the first call, but then leave it NULL for
00356  * subsequent calls, on the theory that if credentials failed, it's
00357  * as likely to be due to incorrect username as incorrect password.
00358  *
00359  * If @a may_save is FALSE, the auth system does not allow the credentials
00360  * to be saved (to disk). A prompt function shall not ask the user if the
00361  * credentials shall be saved if @a may_save is FALSE. For example, a GUI
00362  * client with a remember password checkbox would grey out the checkbox if
00363  * @a may_save is FALSE.
00364  */
00365 typedef svn_error_t *(*svn_auth_simple_prompt_func_t)
00366   (svn_auth_cred_simple_t **cred,
00367    void *baton,
00368    const char *realm,
00369    const char *username,
00370    svn_boolean_t may_save,
00371    apr_pool_t *pool);
00372 
00373 
00374 /** Set @a *cred by prompting the user, allocating @a *cred in @a pool.
00375  * @a baton is an implementation-specific closure.
00376  *
00377  * If @a realm is non-NULL, maybe use it in the prompt string.
00378  *
00379  * If @a may_save is FALSE, the auth system does not allow the credentials
00380  * to be saved (to disk). A prompt function shall not ask the user if the
00381  * credentials shall be saved if @a may_save is FALSE. For example, a GUI
00382  * client with a remember username checkbox would grey out the checkbox if
00383  * @a may_save is FALSE.
00384  */
00385 typedef svn_error_t *(*svn_auth_username_prompt_func_t)
00386   (svn_auth_cred_username_t **cred,
00387    void *baton,
00388    const char *realm,
00389    svn_boolean_t may_save,
00390    apr_pool_t *pool);
00391 
00392 
00393 /** @name SSL server certificate failure bits
00394  *
00395  * @note These values are stored in the on disk auth cache by the SSL
00396  * server certificate auth provider, so the meaning of these bits must
00397  * not be changed.
00398  * @{
00399  */
00400 /** Certificate is not yet valid. */
00401 #define SVN_AUTH_SSL_NOTYETVALID 0x00000001
00402 /** Certificate has expired. */
00403 #define SVN_AUTH_SSL_EXPIRED     0x00000002
00404 /** Certificate's CN (hostname) does not match the remote hostname. */
00405 #define SVN_AUTH_SSL_CNMISMATCH  0x00000004
00406 /** @brief Certificate authority is unknown (i.e. not trusted) */
00407 #define SVN_AUTH_SSL_UNKNOWNCA   0x00000008
00408 /** @brief Other failure. This can happen if neon has introduced a new
00409  * failure bit that we do not handle yet. */
00410 #define SVN_AUTH_SSL_OTHER       0x40000000
00411 /** @} */
00412 
00413 /** Set @a *cred by prompting the user, allocating @a *cred in @a pool.
00414  * @a baton is an implementation-specific closure.
00415  *
00416  * @a cert_info is a structure describing the server cert that was
00417  * presented to the client, and @a failures is a bitmask that
00418  * describes exactly why the cert could not be automatically validated,
00419  * composed from the constants SVN_AUTH_SSL_* (@c SVN_AUTH_SSL_NOTYETVALID
00420  * etc.).  @a realm is a string that can be used in the prompt string.
00421  *
00422  * If @a may_save is FALSE, the auth system does not allow the credentials
00423  * to be saved (to disk). A prompt function shall not ask the user if the
00424  * credentials shall be saved if @a may_save is FALSE. For example, a GUI
00425  * client with a trust permanently checkbox would grey out the checkbox if
00426  * @a may_save is FALSE.
00427  */
00428 typedef svn_error_t *(*svn_auth_ssl_server_trust_prompt_func_t)
00429   (svn_auth_cred_ssl_server_trust_t **cred,
00430    void *baton,
00431    const char *realm,
00432    apr_uint32_t failures,
00433    const svn_auth_ssl_server_cert_info_t *cert_info,
00434    svn_boolean_t may_save,
00435    apr_pool_t *pool);
00436 
00437 
00438 /** Set @a *cred by prompting the user, allocating @a *cred in @a pool.
00439  * @a baton is an implementation-specific closure.  @a realm is a string
00440  * that can be used in the prompt string.
00441  *
00442  * If @a may_save is FALSE, the auth system does not allow the credentials
00443  * to be saved (to disk). A prompt function shall not ask the user if the
00444  * credentials shall be saved if @a may_save is FALSE. For example, a GUI
00445  * client with a remember certificate checkbox would grey out the checkbox
00446  * if @a may_save is FALSE.
00447  */
00448 typedef svn_error_t *(*svn_auth_ssl_client_cert_prompt_func_t)
00449   (svn_auth_cred_ssl_client_cert_t **cred,
00450    void *baton,
00451    const char *realm,
00452    svn_boolean_t may_save,
00453    apr_pool_t *pool);
00454 
00455 
00456 /** Set @a *cred by prompting the user, allocating @a *cred in @a pool.
00457  * @a baton is an implementation-specific closure.  @a realm is a string
00458  * identifying the certificate, and can be used in the prompt string.
00459  *
00460  * If @a may_save is FALSE, the auth system does not allow the credentials
00461  * to be saved (to disk). A prompt function shall not ask the user if the
00462  * credentials shall be saved if @a may_save is FALSE. For example, a GUI
00463  * client with a remember password checkbox would grey out the checkbox if
00464  * @a may_save is FALSE.
00465  */
00466 typedef svn_error_t *(*svn_auth_ssl_client_cert_pw_prompt_func_t)
00467   (svn_auth_cred_ssl_client_cert_pw_t **cred,
00468    void *baton,
00469    const char *realm,
00470    svn_boolean_t may_save,
00471    apr_pool_t *pool);
00472 
00473 /** Called only by providers which save passwords unencrypted.
00474  * In this callback, clients should ask the user whether storing
00475  * a password for the realm identified by @a realmstring to disk
00476  * in plaintext is allowed.
00477  *
00478  * The answer is returned in @a *may_save_plaintext.
00479  * @a baton is an implementation-specific closure.
00480  * All allocations should be done in @a pool.
00481  *
00482  * This callback is called only once per authentication realm,
00483  * not once per RA session. This means that clients implementing
00484  * this callback must make sure that the pool passed to any
00485  * implementation of save_credentials (part of svn_auth_provider_t)
00486  * survives across RA sessions.
00487  *
00488  * If this callback is NULL it is not called. This matches the
00489  * deprecated behaviour of storing unencrypted passwords by default,
00490  * and is only done this way for backward compatibility reasons.
00491  * Client developers are highly encouraged to provide this callback
00492  * to ensure their users are made aware of the fact that their password
00493  * is going to be stored unencrypted. In the future, providers may
00494  * default to not storing the password unencrypted if this callback is NULL.
00495  *
00496  * Clients can however set the callback to NULL and set
00497  * SVN_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS to SVN_CONFIG_FALSE or
00498  * SVN_CONFIG_TRUE to enforce a certain behaviour.
00499  *
00500  * @since New in 1.6
00501  */
00502 typedef svn_error_t *(*svn_auth_plaintext_prompt_func_t)
00503   (svn_boolean_t *may_save_plaintext,
00504    const char *realmstring,
00505    void *baton,
00506    apr_pool_t *pool);
00507 
00508 /** Called only by providers which save passphrase unencrypted.
00509  * In this callback, clients should ask the user whether storing
00510  * a passphrase for the realm identified by @a realmstring to disk
00511  * in plaintext is allowed.
00512  *
00513  * The answer is returned in @a *may_save_plaintext.
00514  * @a baton is an implementation-specific closure.
00515  * All allocations should be done in @a pool.
00516  *
00517  * This callback is called only once per authentication realm,
00518  * not once per RA session. This means that clients implementing
00519  * this callback must make sure that the pool passed to any
00520  * implementation of save_credentials (part of svn_auth_provider_t)
00521  * survives across RA sessions.
00522  *
00523  * If this callback is NULL it is not called.
00524  * Client developers are highly encouraged to provide this callback
00525  * to ensure their users are made aware of the fact that their passphrase
00526  * is going to be stored unencrypted.
00527  *
00528  * Clients can however set the callback to NULL and set
00529  * SVN_AUTH_PARAM_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT to SVN_CONFIG_FALSE or
00530  * SVN_CONFIG_TRUE to enforce a certain behaviour. 
00531  *
00532  * @since New in 1.6
00533  */
00534 typedef svn_error_t *(*svn_auth_plaintext_passphrase_prompt_func_t)
00535   (svn_boolean_t *may_save_plaintext,
00536    const char *realmstring,
00537    void *baton,
00538    apr_pool_t *pool);
00539 
00540 
00541 /** Initialize an authentication system.
00542  *
00543  * Return an authentication object in @a *auth_baton (allocated in @a
00544  * pool) that represents a particular instance of the svn
00545  * authentication system.  @a providers is an array of @c
00546  * svn_auth_provider_object_t pointers, already allocated in @a pool
00547  * and intentionally ordered.  These pointers will be stored within @a
00548  * *auth_baton, grouped by credential type, and searched in this exact
00549  * order.
00550  */
00551 void
00552 svn_auth_open(svn_auth_baton_t **auth_baton,
00553               apr_array_header_t *providers,
00554               apr_pool_t *pool);
00555 
00556 /** Set an authentication run-time parameter.
00557  *
00558  * Store @a name / @a value pair as a run-time parameter in @a
00559  * auth_baton, making the data accessible to all providers.  @a name
00560  * and @a value will NOT be duplicated into the auth_baton's pool.
00561  * To delete a run-time parameter, pass NULL for @a value.
00562  */
00563 void
00564 svn_auth_set_parameter(svn_auth_baton_t *auth_baton,
00565                        const char *name,
00566                        const void *value);
00567 
00568 /** Get an authentication run-time parameter.
00569  *
00570  * Return a value for run-time parameter @a name from @a auth_baton.
00571  * Return NULL if the parameter doesn't exist.
00572  */
00573 const void *
00574 svn_auth_get_parameter(svn_auth_baton_t *auth_baton,
00575                        const char *name);
00576 
00577 /** Universal run-time parameters, made available to all providers.
00578 
00579     If you are writing a new provider, then to be a "good citizen",
00580     you should notice these global parameters!  Note that these
00581     run-time params should be treated as read-only by providers; the
00582     application is responsible for placing them into the auth_baton
00583     hash. */
00584 
00585 /** The auth-hash prefix indicating that the parameter is global. */
00586 #define SVN_AUTH_PARAM_PREFIX "svn:auth:"
00587 
00588 /**
00589  * @name Default credentials defines
00590  * Any 'default' credentials that came in through the application itself,
00591  * (e.g. --username and --password options). Property values are
00592  * const char *.
00593  * @{ */
00594 #define SVN_AUTH_PARAM_DEFAULT_USERNAME  SVN_AUTH_PARAM_PREFIX "username"
00595 #define SVN_AUTH_PARAM_DEFAULT_PASSWORD  SVN_AUTH_PARAM_PREFIX "password"
00596 /** @} */
00597 
00598 /** @brief The application doesn't want any providers to prompt
00599  * users. Property value is irrelevant; only property's existence
00600  * matters. */
00601 #define SVN_AUTH_PARAM_NON_INTERACTIVE  SVN_AUTH_PARAM_PREFIX "non-interactive"
00602 
00603 /** @brief The application doesn't want any providers to save passwords
00604  * to disk. Property value is irrelevant; only property's existence
00605  * matters. */
00606 #define SVN_AUTH_PARAM_DONT_STORE_PASSWORDS  SVN_AUTH_PARAM_PREFIX \
00607                                                  "dont-store-passwords"
00608 
00609 /** @brief Indicates whether providers may save passwords to disk in
00610  * plaintext. Property value can be either SVN_CONFIG_TRUE,
00611  * SVN_CONFIG_FALSE, or SVN_CONFIG_ASK. */
00612 #define SVN_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS  SVN_AUTH_PARAM_PREFIX \
00613                                                   "store-plaintext-passwords"
00614 
00615 /** @brief The application doesn't want any providers to save passphrase
00616  * to disk. Property value is irrelevant; only property's existence
00617  * matters. */
00618 #define SVN_AUTH_PARAM_DONT_STORE_SSL_CLIENT_CERT_PP \
00619   SVN_AUTH_PARAM_PREFIX "dont-store-ssl-client-cert-pp"
00620 
00621 /** @brief Indicates whether providers may save passphrase to disk in
00622  * plaintext. Property value can be either SVN_CONFIG_TRUE,
00623  * SVN_CONFIG_FALSE, or SVN_CONFIG_ASK. */
00624 #define SVN_AUTH_PARAM_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT \
00625   SVN_AUTH_PARAM_PREFIX "store-ssl-client-cert-pp-plaintext"
00626 
00627 /** @brief The application doesn't want any providers to save credentials
00628  * to disk. Property value is irrelevant; only property's existence
00629  * matters. */
00630 #define SVN_AUTH_PARAM_NO_AUTH_CACHE  SVN_AUTH_PARAM_PREFIX "no-auth-cache"
00631 
00632 /** @brief The following property is for SSL server cert providers. This
00633  * provides a pointer to an @c apr_uint32_t containing the failures
00634  * detected by the certificate validator. */
00635 #define SVN_AUTH_PARAM_SSL_SERVER_FAILURES SVN_AUTH_PARAM_PREFIX \
00636   "ssl:failures"
00637 
00638 /** @brief The following property is for SSL server cert providers. This
00639  * provides the cert info (svn_auth_ssl_server_cert_info_t). */
00640 #define SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO SVN_AUTH_PARAM_PREFIX \
00641   "ssl:cert-info"
00642 
00643 /** Some providers need access to the @c svn_config_t configuration. */
00644 #define SVN_AUTH_PARAM_CONFIG SVN_AUTH_PARAM_PREFIX "config"
00645 
00646 /** The current server group. */
00647 #define SVN_AUTH_PARAM_SERVER_GROUP SVN_AUTH_PARAM_PREFIX "server-group"
00648 
00649 /** @brief A configuration directory that overrides the default
00650  * ~/.subversion. */
00651 #define SVN_AUTH_PARAM_CONFIG_DIR SVN_AUTH_PARAM_PREFIX "config-dir"
00652 
00653 /** Get an initial set of credentials.
00654  *
00655  * Ask @a auth_baton to set @a *credentials to a set of credentials
00656  * defined by @a cred_kind and valid within @a realmstring, or NULL if
00657  * no credentials are available.  Otherwise, return an iteration state
00658  * in @a *state, so that the caller can call
00659  * svn_auth_next_credentials(), in case the first set of credentials
00660  * fails to authenticate.
00661  *
00662  * Use @a pool to allocate @a *state, and for temporary allocation.
00663  * Note that @a *credentials will be allocated in @a auth_baton's pool.
00664  */
00665 svn_error_t *
00666 svn_auth_first_credentials(void **credentials,
00667                            svn_auth_iterstate_t **state,
00668                            const char *cred_kind,
00669                            const char *realmstring,
00670                            svn_auth_baton_t *auth_baton,
00671                            apr_pool_t *pool);
00672 
00673 /** Get another set of credentials, assuming previous ones failed to
00674  * authenticate.
00675  *
00676  * Use @a state to fetch a different set of @a *credentials, as a
00677  * follow-up to svn_auth_first_credentials() or
00678  * svn_auth_next_credentials().  If no more credentials are available,
00679  * set @a *credentials to NULL.
00680  *
00681  * Note that @a *credentials will be allocated in @c auth_baton's pool.
00682  */
00683 svn_error_t *
00684 svn_auth_next_credentials(void **credentials,
00685                           svn_auth_iterstate_t *state,
00686                           apr_pool_t *pool);
00687 
00688 /** Save a set of credentials.
00689  *
00690  * Ask @a state to store the most recently returned credentials,
00691  * presumably because they successfully authenticated.
00692  * All allocations should be done in @a pool, which is
00693  * assumed to survive across RA sessions; auth providers that store
00694  * passwords in plaintext rely on this.
00695  *
00696  * If no credentials were ever returned, do nothing.
00697  */
00698 svn_error_t *
00699 svn_auth_save_credentials(svn_auth_iterstate_t *state,
00700                           apr_pool_t *pool);
00701 
00702 /** @} */
00703 
00704 /** Create and return @a *provider, an authentication provider of type
00705  * svn_auth_cred_simple_t that gets information by prompting the user
00706  * with @a prompt_func and @a prompt_baton.  Allocate @a *provider in
00707  * @a pool.
00708  *
00709  * If both @c SVN_AUTH_PARAM_DEFAULT_USERNAME and
00710  * @c SVN_AUTH_PARAM_DEFAULT_PASSWORD are defined as runtime
00711  * parameters in the @c auth_baton, then @a *provider will return the
00712  * default arguments when svn_auth_first_credentials() is called.  If
00713  * svn_auth_first_credentials() fails, then @a *provider will
00714  * re-prompt @a retry_limit times (via svn_auth_next_credentials()).
00715  *
00716  * @since New in 1.4.
00717  */
00718 void
00719 svn_auth_get_simple_prompt_provider(svn_auth_provider_object_t **provider,
00720                                     svn_auth_simple_prompt_func_t prompt_func,
00721                                     void *prompt_baton,
00722                                     int retry_limit,
00723                                     apr_pool_t *pool);
00724 
00725 
00726 /** Create and return @a *provider, an authentication provider of type @c
00727  * svn_auth_cred_username_t that gets information by prompting the
00728  * user with @a prompt_func and @a prompt_baton.  Allocate @a *provider
00729  * in @a pool.
00730  *
00731  * If @c SVN_AUTH_PARAM_DEFAULT_USERNAME is defined as a runtime
00732  * parameter in the @c auth_baton, then @a *provider will return the
00733  * default argument when svn_auth_first_credentials() is called.  If
00734  * svn_auth_first_credentials() fails, then @a *provider will
00735  * re-prompt @a retry_limit times (via svn_auth_next_credentials()).
00736  *
00737  * @since New in 1.4.
00738  */
00739 void
00740 svn_auth_get_username_prompt_provider
00741   (svn_auth_provider_object_t **provider,
00742    svn_auth_username_prompt_func_t prompt_func,
00743    void *prompt_baton,
00744    int retry_limit,
00745    apr_pool_t *pool);
00746 
00747 
00748 /** Create and return @a *provider, an authentication provider of type @c
00749  * svn_auth_cred_simple_t that gets/sets information from the user's
00750  * ~/.subversion configuration directory.
00751  *
00752  * If the provider is going to save the password unencrypted,
00753  * it calls @a plaintext_prompt_func before saving the
00754  * password.
00755  *
00756  * @a prompt_baton is passed to @a plaintext_prompt_func.
00757  *
00758  * Allocate @a *provider in @a pool.
00759  *
00760  * If a default username or password is available, @a *provider will
00761  * honor them as well, and return them when
00762  * svn_auth_first_credentials() is called.  (see @c
00763  * SVN_AUTH_PARAM_DEFAULT_USERNAME and @c
00764  * SVN_AUTH_PARAM_DEFAULT_PASSWORD).
00765  *
00766  * @since New in 1.6.
00767  */
00768 void
00769 svn_auth_get_simple_provider2
00770   (svn_auth_provider_object_t **provider,
00771    svn_auth_plaintext_prompt_func_t plaintext_prompt_func,
00772    void* prompt_baton,
00773    apr_pool_t *pool);
00774 
00775 /** Like svn_auth_get_simple_provider2, but without the ability to
00776  * call the svn_auth_plaintext_prompt_func_t callback.
00777  *
00778  * @deprecated Provided for backwards compatibility with the 1.5 API.
00779  * @since New in 1.4.
00780  */
00781 SVN_DEPRECATED
00782 void
00783 svn_auth_get_simple_provider(svn_auth_provider_object_t **provider,
00784                              apr_pool_t *pool);
00785 
00786 
00787 #if (defined(WIN32) && !defined(__MINGW32__)) || defined(DOXYGEN)
00788 /**
00789  * Create and return @a *provider, an authentication provider of type @c
00790  * svn_auth_cred_simple_t that gets/sets information from the user's
00791  * ~/.subversion configuration directory.  Allocate @a *provider in
00792  * @a pool.
00793  *
00794  * This is like svn_auth_get_simple_provider(), except that, when
00795  * running on Window 2000 or newer (or any other Windows version that
00796  * includes the CryptoAPI), the provider encrypts the password before
00797  * storing it to disk. On earlier versions of Windows, the provider
00798  * does nothing.
00799  *
00800  * @since New in 1.4.
00801  * @note This function is only available on Windows.
00802  *
00803  * @note An administrative password reset may invalidate the account's
00804  * secret key. This function will detect that situation and behave as
00805  * if the password were not cached at all.
00806  */
00807 void
00808 svn_auth_get_windows_simple_provider(svn_auth_provider_object_t **provider,
00809                                      apr_pool_t *pool);
00810 #endif /* WIN32 || DOXYGEN */
00811 
00812 #if defined(DARWIN) || defined(DOXYGEN)
00813 /**
00814  * Create and return @a *provider, an authentication provider of type @c
00815  * svn_auth_cred_simple_t that gets/sets information from the user's
00816  * ~/.subversion configuration directory.  Allocate @a *provider in
00817  * @a pool.
00818  *
00819  * This is like svn_auth_get_simple_provider(), except that the
00820  * password is stored in the Mac OS KeyChain.
00821  *
00822  * @since New in 1.4
00823  * @note This function is only available on Mac OS 10.2 and higher.
00824  */
00825 void
00826 svn_auth_get_keychain_simple_provider(svn_auth_provider_object_t **provider,
00827                                       apr_pool_t *pool);
00828 
00829 /**
00830  * Create and return @a *provider, an authentication provider of type @c
00831  * svn_auth_cred_ssl_client_cert_pw_t that gets/sets information from the
00832  * user's ~/.subversion configuration directory.  Allocate @a *provider in
00833  * @a pool.
00834  *
00835  * This is like svn_auth_get_ssl_client_cert_pw_file_provider(), except
00836  * that the password is stored in the Mac OS KeyChain.
00837  *
00838  * @since New in 1.6
00839  * @note This function is only available on Mac OS 10.2 and higher.
00840  */
00841 void
00842 svn_auth_get_keychain_ssl_client_cert_pw_provider
00843   (svn_auth_provider_object_t **provider,
00844    apr_pool_t *pool);
00845 #endif /* DARWIN || DOXYGEN */
00846 
00847 
00848 /** Create and return @a *provider, an authentication provider of type @c
00849  * svn_auth_cred_username_t that gets/sets information from a user's
00850  * ~/.subversion configuration directory.  Allocate @a *provider in
00851  * @a pool.
00852  *
00853  * If a default username is available, @a *provider will honor it,
00854  * and return it when svn_auth_first_credentials() is called.  (See
00855  * @c SVN_AUTH_PARAM_DEFAULT_USERNAME.)
00856  *
00857  * @since New in 1.4.
00858  */
00859 void
00860 svn_auth_get_username_provider(svn_auth_provider_object_t **provider,
00861                                apr_pool_t *pool);
00862 
00863 
00864 /** Create and return @a *provider, an authentication provider of type @c
00865  * svn_auth_cred_ssl_server_trust_t, allocated in @a pool.
00866  *
00867  * @a *provider retrieves its credentials from the configuration
00868  * mechanism.  The returned credential is used to override SSL
00869  * security on an error.
00870  *
00871  * @since New in 1.4.
00872  */
00873 void
00874 svn_auth_get_ssl_server_trust_file_provider
00875   (svn_auth_provider_object_t **provider,
00876    apr_pool_t *pool);
00877 
00878 
00879 #if (defined(WIN32) && !defined(__MINGW32__)) || defined(DOXYGEN)
00880 /**
00881  * Create and return @a *provider, an authentication provider of type @c
00882  * svn_auth_cred_ssl_server_trust_t, allocated in @a pool.
00883  *
00884  * This provider automatically validates ssl server certificates with
00885  * the CryptoApi, like Internet Explorer and the Windows network API do.
00886  * This allows the rollout of root certificates via Windows Domain
00887  * policies, instead of Subversion specific configuration.
00888  *
00889  * @since New in 1.5.
00890  * @note This function is only available on Windows.
00891  */
00892 void
00893 svn_auth_get_windows_ssl_server_trust_provider
00894   (svn_auth_provider_object_t **provider,
00895    apr_pool_t *pool);
00896 #endif /* WIN32 || DOXYGEN */
00897 
00898 /** Create and return @a *provider, an authentication provider of type @c
00899  * svn_auth_cred_ssl_client_cert_t, allocated in @a pool.
00900  *
00901  * @a *provider retrieves its credentials from the configuration
00902  * mechanism.  The returned credential is used to load the appropriate
00903  * client certificate for authentication when requested by a server.
00904  *
00905  * @since New in 1.4.
00906  */
00907 void
00908 svn_auth_get_ssl_client_cert_file_provider
00909   (svn_auth_provider_object_t **provider,
00910    apr_pool_t *pool);
00911 
00912 
00913 /** Create and return @a *provider, an authentication provider of type @c
00914  * svn_auth_cred_ssl_client_cert_pw_t that gets/sets information from the user's
00915  * ~/.subversion configuration directory.
00916  *
00917  * If the provider is going to save the passphrase unencrypted,
00918  * it calls @a plaintext_passphrase_prompt_func before saving the
00919  * passphrase.
00920  *
00921  * @a prompt_baton is passed to @a plaintext_passphrase_prompt_func.
00922  *
00923  * Allocate @a *provider in @a pool.
00924  *
00925  * @since New in 1.6.
00926  */
00927 void
00928 svn_auth_get_ssl_client_cert_pw_file_provider2
00929   (svn_auth_provider_object_t **provider,
00930    svn_auth_plaintext_passphrase_prompt_func_t plaintext_passphrase_prompt_func,
00931    void *prompt_baton,
00932    apr_pool_t *pool);
00933 
00934 /** Like svn_auth_get_ssl_client_cert_pw_file_provider2, but without
00935  * the ability to call the svn_auth_plaintext_passphrase_prompt_func_t
00936  * callback.
00937  *
00938  * @deprecated Provided for backwards compatibility with the 1.5 API.
00939  * @since New in 1.4.
00940  */
00941 SVN_DEPRECATED
00942 void
00943 svn_auth_get_ssl_client_cert_pw_file_provider
00944   (svn_auth_provider_object_t **provider,
00945    apr_pool_t *pool);
00946 
00947 
00948 /** Create and return @a *provider, an authentication provider of type @c
00949  * svn_auth_cred_ssl_server_trust_t, allocated in @a pool.
00950  *
00951  * @a *provider retrieves its credentials by using the @a prompt_func
00952  * and @a prompt_baton.  The returned credential is used to override
00953  * SSL security on an error.
00954  *
00955  * @since New in 1.4.
00956  */
00957 void
00958 svn_auth_get_ssl_server_trust_prompt_provider
00959   (svn_auth_provider_object_t **provider,
00960    svn_auth_ssl_server_trust_prompt_func_t prompt_func,
00961    void *prompt_baton,
00962    apr_pool_t *pool);
00963 
00964 
00965 /** Create and return @a *provider, an authentication provider of type @c
00966  * svn_auth_cred_ssl_client_cert_t, allocated in @a pool.
00967  *
00968  * @a *provider retrieves its credentials by using the @a prompt_func
00969  * and @a prompt_baton.  The returned credential is used to load the
00970  * appropriate client certificate for authentication when requested by
00971  * a server.  The prompt will be retried @a retry_limit times.
00972  *
00973  * @since New in 1.4.
00974  */
00975 void
00976 svn_auth_get_ssl_client_cert_prompt_provider
00977   (svn_auth_provider_object_t **provider,
00978    svn_auth_ssl_client_cert_prompt_func_t prompt_func,
00979    void *prompt_baton,
00980    int retry_limit,
00981    apr_pool_t *pool);
00982 
00983 
00984 /** Create and return @a *provider, an authentication provider of type @c
00985  * svn_auth_cred_ssl_client_cert_pw_t, allocated in @a pool.
00986  *
00987  * @a *provider retrieves its credentials by using the @a prompt_func
00988  * and @a prompt_baton.  The returned credential is used when a loaded
00989  * client certificate is protected by a passphrase.  The prompt will
00990  * be retried @a retry_limit times.
00991  *
00992  * @since New in 1.4.
00993  */
00994 void
00995 svn_auth_get_ssl_client_cert_pw_prompt_provider
00996   (svn_auth_provider_object_t **provider,
00997    svn_auth_ssl_client_cert_pw_prompt_func_t prompt_func,
00998    void *prompt_baton,
00999    int retry_limit,
01000    apr_pool_t *pool);
01001 
01002 #ifdef __cplusplus
01003 }
01004 #endif /* __cplusplus */
01005 
01006 #endif /* SVN_AUTH_H */

Generated on Sun Sep 7 04:06:59 2008 for Subversion by  doxygen 1.3.9.1