Skip to content

Commit

Permalink
[telepathy-sasl-signon] Use libsailfishkeyprovider to load privileged…
Browse files Browse the repository at this point in the history
… oauth2 data
  • Loading branch information
John Brooks committed Sep 6, 2013
1 parent 2a84da0 commit 4281080
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions rpm/telepathy-accounts-signon.spec
Expand Up @@ -16,6 +16,8 @@ BuildRequires: pkgconfig(libaccounts-glib)
BuildRequires: pkgconfig(libsoup-2.4)
BuildRequires: pkgconfig(mission-control-plugins)

BuildRequires: pkgconfig(libsailfishkeyprovider)

%description
%{summary}.

Expand Down
24 changes: 20 additions & 4 deletions telepathy-sasl-signon/empathy-uoa-auth-handler.c
Expand Up @@ -27,6 +27,8 @@
#include <libsignon-glib/signon-identity.h>
#include <libsignon-glib/signon-auth-session.h>

#include <sailfishkeyprovider.h>

#define DEBUG_FLAG EMPATHY_DEBUG_SASL
#include "empathy-debug.h"
#include "empathy-keyring.h"
Expand Down Expand Up @@ -86,6 +88,7 @@ typedef struct
SignonAuthSession *session;

gchar *username;
gchar *client_id;
} AuthContext;

static AuthContext *
Expand Down Expand Up @@ -116,6 +119,9 @@ auth_context_new (TpChannel *channel,
if (ctx->session == NULL)
goto out;

ctx->username = 0;
ctx->client_id = 0;

out:
return ctx;
}
Expand All @@ -129,6 +135,7 @@ auth_context_free (AuthContext *ctx)
g_clear_object (&ctx->session);
g_clear_object (&ctx->identity);
g_free (ctx->username);
g_free (ctx->client_id);

g_slice_free (AuthContext, ctx);
}
Expand Down Expand Up @@ -223,15 +230,13 @@ session_process_cb (SignonAuthSession *session,
}

access_token = tp_asv_get_string (session_data, "AccessToken");
client_id = tp_asv_get_string (ag_auth_data_get_parameters (ctx->auth_data),
"ClientId");
auth_method = signon_auth_session_get_method (session);

switch (empathy_sasl_channel_select_mechanism (ctx->channel, auth_method))
{
case EMPATHY_SASL_MECHANISM_FACEBOOK:
empathy_sasl_auth_facebook_async (ctx->channel,
client_id, access_token,
ctx->client_id, access_token,
auth_cb, ctx);
break;

Expand Down Expand Up @@ -282,8 +287,19 @@ identity_query_info_cb (SignonIdentity *identity,
DEBUG ("No username in signon data, falling back to account display name (%s) as username", ctx->username);
}

GHashTable *params = ag_auth_data_get_parameters (ctx->auth_data);
AgService *service = ag_account_service_get_service (ctx->service);

SailfishKeyProvider_storedKey (ag_service_get_provider (service),
ag_service_get_name (service), "client_id", &ctx->client_id);

if (ctx->client_id)
{
tp_asv_set_string (params, "ClientId", ctx->client_id);
}

signon_auth_session_process (ctx->session,
ag_auth_data_get_parameters (ctx->auth_data),
params,
ag_auth_data_get_mechanism (ctx->auth_data),
session_process_cb,
ctx);
Expand Down
1 change: 1 addition & 0 deletions telepathy-sasl-signon/telepathy-sasl-signon.pro
Expand Up @@ -3,6 +3,7 @@ CONFIG -= qt

CONFIG += link_pkgconfig
PKGCONFIG += libsignon-glib telepathy-glib libaccounts-glib libsoup-2.4
PKGCONFIG += libsailfishkeyprovider

DEFINES += HAVE_UOA \
EMPATHY_UOA_PROVIDER=\\\"im.telepathy.Account.Storage.UOA\\\"
Expand Down

0 comments on commit 4281080

Please sign in to comment.