From d84f3233981d80ea3436a21f8c6a89b1a4a61731 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 13 Feb 2015 07:50:28 -0800 Subject: [PATCH 6/7] 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. --- src/backends/signon/signon-accounts.cpp | 3 ++- src/backends/signon/signon.h | 8 ++++++++ src/backends/signon/signonRegister.cpp | 12 ++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/backends/signon/signon-accounts.cpp b/src/backends/signon/signon-accounts.cpp index d8f67dc..488a0e6 100644 --- a/src/backends/signon/signon-accounts.cpp +++ b/src/backends/signon/signon-accounts.cpp @@ -20,6 +20,7 @@ #include #include +#include "signon.h" #ifdef USE_SIGNON #ifdef USE_GSSO @@ -221,7 +222,7 @@ boost::shared_ptr createSignonAuthProvider(const InitStateString & AgAccountId accountID; std::string serviceName; if (!re.FullMatch(username, &accountID, &serviceName)) { - SE_THROW(StringPrintf("username must have the format gsso:,: %s", + SE_THROW(StringPrintf("username must have the format " SE_SIGNON_PROVIDER_ID ":,: %s", username.c_str())); } SE_LOG_DEBUG(NULL, "looking up account ID %d and service '%s'", diff --git a/src/backends/signon/signon.h b/src/backends/signon/signon.h index 7843ab0..f4b9ef6 100644 --- a/src/backends/signon/signon.h +++ b/src/backends/signon/signon.h @@ -26,6 +26,14 @@ #include 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 createSignonAuthProvider(const InitStateString &username, const InitStateString &password); diff --git a/src/backends/signon/signonRegister.cpp b/src/backends/signon/signonRegister.cpp index 8f8c0e0..bb3316a 100644 --- a/src/backends/signon/signonRegister.cpp +++ b/src/backends/signon/signonRegister.cpp @@ -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:[,]\n" + IdentityProvider(SE_SIGNON_PROVIDER_ID, + SE_SIGNON_PROVIDER_ID ":[,]\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:[,]\n" + IdentityProvider(SE_SIGNON_PROVIDER_ID, + SE_SIGNON_PROVIDER_ID ":[,]\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:]\n" + IdentityProvider(SE_SIGNON_PROVIDER_ID, + SE_SIGNON_PROVIDER_ID ":]\n" " Authentication using libgsignond with an identity created\n" " before calling SyncEvolution. The string is a\n" " GVariant text dump suitable for g_variant_parse() (see\n" -- 2.1.4