You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Justin Erenkrantz je...@apache.org on 2003/01/24 05:46:42 UTC

Semantics of svn_auth_save_credentials?

Within svn_auth.h, we have:

/** Save a set of credentials.
 *
 * Ask @a auth_baton to store @a credentials (of type @a cred_kind)
 * for future use.  Presumably these credentials authenticated
 * successfully.  Use @a pool for temporary allocation.  If no
 * provider is able to store the credentials, return error.
 */
svn_error_t * svn_auth_save_credentials(const char *cred_kind,
                                        void *credentials,
                                        svn_auth_baton_t *auth_baton,
                                        apr_pool_t *pool);

I have to say that the implied semantics trouble me.  Exactly what 
provider should 'save' a particular credential?  The first provider? 
All of them?

I'd also suggest that a provider be allowed to have a NULL function 
pointer to save_credentials rather than implement a stub that returns 
false.  That makes it much easier for providers - a little more work 
for the caller perhaps.  -- justin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

RE: Semantics of svn_auth_save_credentials?

Posted by Sander Striker st...@apache.org.
 From: sussman@collab.net [mailto:sussman@collab.net]
 Sent: Friday, January 24, 2003 7:04 PM

 Sander Striker striker@apache.org writes:
 
   Now, you could say that because the user placed the 'file' provider 
   first that that is their 'preferred' provider.  But, I'm not sure 
   that's exactly what we would want.  Is it?  -- justin
  
  It is likely that we wish to update creds in the provider we got them
  from.  We would need to save the provider and the old creds and pass
  those optionally to the save function.  This should then first
  try the passed in provider and see if it can update the old creds.
  If not, it should start at the first provider and cycle through them
  until it finds one that wishes to store the new creds (or it doesn't
  find one ofcourse).
 
 This makes sense to me.  All we have to do is make the public
 svn_auth_save_creds() function take the iteration baton that was
 already being used by svn_auth_first_creds() and
 svn_auth_next_creds().  The iteration baton *already* remembers which
 provider was last called.

*nod*

We just need a function to dup the baton, so we can get to it later.
Reason for this is that the current pool we are using might get cleared/
destroyed, while we may want to retain the iteration baton (by storing
it in a long lived pool).  Use case: GUI client.

Sander

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Semantics of svn_auth_save_credentials?

Posted by Ben Collins-Sussman su...@collab.net.
Sander Striker striker@apache.org writes:

  Now, you could say that because the user placed the 'file' provider 
  first that that is their 'preferred' provider.  But, I'm not sure 
  that's exactly what we would want.  Is it?  -- justin
 
 It is likely that we wish to update creds in the provider we got them
 from.  We would need to save the provider and the old creds and pass
 those optionally to the save function.  This should then first
 try the passed in provider and see if it can update the old creds.
 If not, it should start at the first provider and cycle through them
 until it finds one that wishes to store the new creds (or it doesn't
 find one ofcourse).

This makes sense to me.  All we have to do is make the public
svn_auth_save_creds() function take the iteration baton that was
already being used by svn_auth_first_creds() and
svn_auth_next_creds().  The iteration baton *already* remembers which
provider was last called.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

RE: Semantics of svn_auth_save_credentials?

Posted by Sander Striker st...@apache.org.
 From: Justin Erenkrantz [mailto:jerenkrantz@apache.org]
 Sent: Friday, January 24, 2003 6:29 PM

[...]
 I guess I'd rather see the saving correlated with the provider.
 
 Imagine this scenario:
 
 1) User backing store #1 (file)
 2) User backing store #2 (dbm)
 3) Keyboard
 
 Say we find a match in provider #2 (all the ones in provider 1 fail). 
 We authenticate successfully.

 Furthermore, let's add the assumption 
 that we're fairly advanced and we have a procedure within the client 
 to change the user's password.  So, we now update the credentials for 
 this user with a new password.

 What would be nice would be to replace the old credentials in the dbm 
 with the new one.  So, if we were to store the originating provider 
 as a key in the credentials, we could then 'update' the credentials.
 
 Now, you could say that because the user placed the 'file' provider 
 first that that is their 'preferred' provider.  But, I'm not sure 
 that's exactly what we would want.  Is it?  -- justin

It is likely that we wish to update creds in the provider we got them
from.  We would need to save the provider and the old creds and pass
those optionally to the save function.  This should then first
try the passed in provider and see if it can update the old creds.
If not, it should start at the first provider and cycle through them
until it finds one that wishes to store the new creds (or it doesn't
find one ofcourse).

Sander

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Semantics of svn_auth_save_credentials?

Posted by Justin Erenkrantz je...@apache.org.
--On Friday, January 24, 2003 10:59 AM -0600 Ben Collins-Sussman 
sussman@collab.net wrote:

 In other words, a provider can refuse to save.  For example, the
 provider which prompts people for username/password -- it makes no
 sense for it to know how to save anything.  But a provider which
 fetches data from .svn/auth/ or ~/.subversion/ should know how to
 store data.

 libsvn_auth just walks over each provider in turn, until some
 provider claims to have saved the data.

I guess I'd rather see the saving correlated with the provider.

Imagine this scenario:

1) User backing store #1 (file)
2) User backing store #2 (dbm)
3) Keyboard

Say we find a match in provider #2 (all the ones in provider 1 fail). 
We authenticate successfully.  Furthermore, let's add the assumption 
that we're fairly advanced and we have a procedure within the client 
to change the user's password.  So, we now update the credentials for 
this user with a new password.

What would be nice would be to replace the old credentials in the dbm 
with the new one.  So, if we were to store the originating provider 
as a key in the credentials, we could then 'update' the credentials.

Now, you could say that because the user placed the 'file' provider 
first that that is their 'preferred' provider.  But, I'm not sure 
that's exactly what we would want.  Is it?  -- justin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Semantics of svn_auth_save_credentials?

Posted by Ben Collins-Sussman su...@collab.net.
Justin Erenkrantz jerenkrantz@apache.org writes:

 Within svn_auth.h, we have:
 
 /** Save a set of credentials.
  *
  * Ask @a auth_baton to store @a credentials (of type @a cred_kind)
  * for future use.  Presumably these credentials authenticated
  * successfully.  Use @a pool for temporary allocation.  If no
  * provider is able to store the credentials, return error.
  */
 svn_error_t * svn_auth_save_credentials(const char *cred_kind,
                                         void *credentials,
                                         svn_auth_baton_t *auth_baton,
                                         apr_pool_t *pool);
 
 I have to say that the implied semantics trouble me.  Exactly what
 provider should 'save' a particular credential?  The first provider?
 All of them?

If you read the documentation for the provider vtable, you'll see:


 /** Save credentials.
   *
   * Store @a credentials for future use.  @a provider_baton is
   * general context for the vtable.  Set @a *saved to true if the
   * save happened, or false if not.  (The provider is not required to
   * save; if it refuses or is unable to save, return false.)
   */
  svn_error_t * (*save_credentials) (svn_boolean_t *saved,
                                     void *credentials,
                                     void *provider_baton,
                                     apr_pool_t *pool);

In other words, a provider can refuse to save.  For example, the
provider which prompts people for username/password -- it makes no
sense for it to know how to save anything.  But a provider which
fetches data from .svn/auth/ or ~/.subversion/ should know how to
store data.

libsvn_auth just walks over each provider in turn, until some provider
claims to have saved the data.

 I'd also suggest that a provider be allowed to have a NULL function
 pointer to save_credentials rather than implement a stub that returns
 false.  That makes it much easier for providers - a little more work
 for the caller perhaps.  -- justin

Sure, that's a good idea.  I'll add that as an option.  Thus a
provider can do any number of things:

 1. not implement a save function at all
 2. implement a save function, but refuse/fail to save for nonfatal reasons
 3. implement a save function, but throw a *real* error when trying to save
 4. implement a save function, and complete the save successfully.

Only libsvn_auth has to understand the conditions... I'll make it so.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Semantics of svn_auth_save_credentials?

Posted by Greg Stein gs...@lyra.org.
On Thu, Jan 23, 2003 at 09:46:42PM -0800, Justin Erenkrantz wrote:
...
 I have to say that the implied semantics trouble me.  Exactly what 
 provider should 'save' a particular credential?  The first provider? 
 All of them?

The first one that saves it. Presumably, that implies that on a read, it
will be the early one that responds with the credentials.

 I'd also suggest that a provider be allowed to have a NULL function 
 pointer to save_credentials rather than implement a stub that returns 
 false.  That makes it much easier for providers - a little more work 
 for the caller perhaps.  -- justin

Yup.

We talked about that, along with a NULL func ptr for next. Many providers
will only have a single set of credentials, so it is a bit silly to
implement a next that only returns NULL.

(this is also the reason why I conflated get-iterator and the first call to
 the iterator; get-first-cred performs those two, then you have NULL for the
 next func)

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org