[Evolution-hackers] Camel Authentication Changes



Just a heads up that I've changed Camel's authentication API to factor
out the password loop that each and every provider currently replicates
for themselves.  Turns out they all have the same basic logic flow.

These changes make password management more consistent and also make
life easier for providers.  Now when a provider reaches the step where
it needs to authenticate, it simply calls: 


  gboolean  camel_session_authenticate_sync  (CamelSession *session,
                                              CamelService *service,
                                              const gchar *mechanism,
                                              GCancellable *cancellable,
                                              GError **error);


The "mechanism" argument refers to the user's preferred SASL mechanism.
This will usually be taken from "url->authmech" but it can also be NULL
when not using SASL (such as for HTTP-based backends).

The CamelSession (or subclass) now handles all the looping.  So if the
function returns TRUE, you're authenticated.  If it returns FALSE, you
treat it like any other failed operation.  You don't loop.

Also, each provider must implement a new CamelServiceClass method: 


  CamelAuthenticationResult
                       (*authenticate_sync)  (CamelService *service,
                                              const gchar *mechanism,
                                              GCancellable *cancellable,
                                              GError **error);


  typedef enum {
      CAMEL_AUTHENTICATION_ERROR,    /* something went horribly wrong! */
      CAMEL_AUTHENTICATION_ACCEPTED, /* auth credentials were accepted */
      CAMEL_AUTHENTICATION_REJECTED  /* auth credentials were rejected */
  } CamelAuthenticationResult;


Most providers already have some kind of internal "try_auth" type of
function, which is all this really is.  Just more formalized now.

This method is to make ONE authentication attempt using the given SASL
mechanism name and return an appropriate result code.  I think this is
pretty self-explanatory.  Returning CAMEL_AUTHENTICATION_ERROR implies
the GError was set.


I'm going to need this API for the password dialog I'm writing for the
new D-Bus service (evolution-source-registry).

Rather than disappearing immediately, the dialog will stay visible until
authentication is confirmed.  If the wrong password was given, it does
that jiggle-the-window thing and then refocuses the password entry.

These API changes are already in master for 3.3.1.

(Insert the usual disclaimer about regressions... let me know of any.)


Oh, also, I'm leaving the old CamelSession.get_password() method alone
because we have a few weird corner cases still using it (namely the GPG
cipher and POPB4SMTP) and I don't want to deal with those right now.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]