signon: ensure consistent use of "username" provider prefix

The Ubuntu Online Accounts signon backend complained about
invalid "username" content with an error message containing "sso",
the string used for gSSO.

Define these magic strings once and then use only the defines.
This commit is contained in:
Patrick Ohly 2015-02-13 07:50:28 -08:00
parent 9acfd11de7
commit d84f323398
3 changed files with 16 additions and 7 deletions

View File

@ -20,6 +20,7 @@
#include <config.h>
#include <syncevo/IdentityProvider.h>
#include "signon.h"
#ifdef USE_SIGNON
#ifdef USE_GSSO
@ -221,7 +222,7 @@ boost::shared_ptr<AuthProvider> createSignonAuthProvider(const InitStateString &
AgAccountId accountID;
std::string serviceName;
if (!re.FullMatch(username, &accountID, &serviceName)) {
SE_THROW(StringPrintf("username must have the format gsso:<account ID>,<service name>: %s",
SE_THROW(StringPrintf("username must have the format " SE_SIGNON_PROVIDER_ID ":<account ID>,<service name>: %s",
username.c_str()));
}
SE_LOG_DEBUG(NULL, "looking up account ID %d and service '%s'",

View File

@ -26,6 +26,14 @@
#include <syncevo/declarations.h>
SE_BEGIN_CXX
#if defined(USE_ACCOUNTS) && defined(USE_GSSO) || defined(STATIC_GSSO)
# define SE_SIGNON_PROVIDER_ID "gsso"
#elif defined(USE_ACCOUNTS) && defined(USE_UOA) || defined(STATIC_UOA)
# define SE_SIGNON_PROVIDER_ID "uoa"
#elif defined(USE_SIGNON) || defined(STATIC_SIGNON)
# define SE_SIGNON_PROVIDER_ID "signon"
#endif
class AuthProvider;
boost::shared_ptr<AuthProvider> createSignonAuthProvider(const InitStateString &username,
const InitStateString &password);

View File

@ -37,22 +37,22 @@ public:
// same time, then this perhaps should be "signon" instead, which then would
// pick either a gSSO or UAO backend depending on which is available.
#if defined(USE_ACCOUNTS) && defined(USE_GSSO) || defined(STATIC_GSSO)
IdentityProvider("gsso",
"gsso:<numeric account ID>[,<service name>]\n"
IdentityProvider(SE_SIGNON_PROVIDER_ID,
SE_SIGNON_PROVIDER_ID ":<numeric account ID>[,<service name>]\n"
" Authentication using libgsignond + libaccounts,\n"
" using an account created and managed with libaccounts.\n"
" The service name is optional. If not given, the\n"
" settings from the account will be used.")
#elif defined(USE_ACCOUNTS) && defined(USE_UOA) || defined(STATIC_UOA)
IdentityProvider("uoa",
"uoa:<numeric account ID>[,<service name>]\n"
IdentityProvider(SE_SIGNON_PROVIDER_ID,
SE_SIGNON_PROVIDER_ID ":<numeric account ID>[,<service name>]\n"
" Authentication using libsignon + libaccounts,\n"
" using an account created and managed with libaccounts.\n"
" The service name is optional. If not given, the\n"
" settings from the account will be used.")
#elif defined(USE_SIGNON) || defined(STATIC_SIGNON)
IdentityProvider("signon",
"signon:<parameters>]\n"
IdentityProvider(SE_SIGNON_PROVIDER_ID,
SE_SIGNON_PROVIDER_ID ":<parameters>]\n"
" Authentication using libgsignond with an identity created\n"
" before calling SyncEvolution. The <parameters> string is a\n"
" GVariant text dump suitable for g_variant_parse() (see\n"