From 4a5d88504235e1df5d01a3a5701b83dd82d6695d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 26 Jul 2011 12:58:38 +0100 Subject: Working OAuth2 support. Needs some more debugging (error handling is not great and imc_logout() gets (rightfully) confused when jabber_data is empty). --- protocols/jabber/jabber.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'protocols/jabber/jabber.h') diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index adf9a291..8d65a7e3 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -92,6 +92,8 @@ struct jabber_data char *username; /* USERNAME@server */ char *server; /* username@SERVER -=> server/domain, not hostname */ + char *oauth2_access_token; + /* After changing one of these two (or the priority setting), call presence_send_update() to inform the server about the changes. */ const struct jabber_away_state *away_state; @@ -231,6 +233,9 @@ struct jabber_transfer #define XMLNS_BYTESTREAMS "http://jabber.org/protocol/bytestreams" /* XEP-0065 */ #define XMLNS_IBB "http://jabber.org/protocol/ibb" /* XEP-0047 */ +/* jabber.c */ +void jabber_connect( struct im_connection *ic ); + /* iq.c */ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ); int jabber_init_iq_auth( struct im_connection *ic ); @@ -315,6 +320,9 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data ); xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data ); xt_status sasl_pkt_result( struct xt_node *node, gpointer data ); gboolean sasl_supported( struct im_connection *ic ); +void sasl_oauth2_init( struct im_connection *ic ); +int sasl_oauth2_get_refresh_token( struct im_connection *ic, const char *msg ); +int sasl_oauth2_refresh( struct im_connection *ic, const char *refresh_token ); /* conference.c */ struct groupchat *jabber_chat_join( struct im_connection *ic, const char *room, const char *nick, const char *password ); -- cgit v1.2.3 From e1c926f53750ca288f30f3d62eecdc763b67d642 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 31 Jul 2011 16:44:37 +0100 Subject: Facebook authentication. This isn't really OAuth in the end: FB doesn't really support desktop app OAuth in a way that would work with BitlBee. Plus, it's only OAuth-compliant by, err, name? --- protocols/jabber/jabber.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'protocols/jabber/jabber.h') diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 8d65a7e3..c68ae343 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -46,6 +46,8 @@ typedef enum activates all XEP-85 related code. */ JFLAG_XMLCONSOLE = 64, /* If the user added an xmlconsole buddy. */ JFLAG_STARTTLS_DONE = 128, /* If a plaintext session was converted to TLS. */ + + JFLAG_SASL_FB = 0x10000, /* Trying Facebook authentication. */ } jabber_flags_t; typedef enum -- cgit v1.2.3 From 18c6d369d777a1d38ef450f868c22de1d0ebba2d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 18 Dec 2011 20:25:44 +0100 Subject: More generic OAuth support now. Should work well for all GTalk accounts now and somewhat for MS Messenger. The fb part needs different parsing of the authorize request, and possibly some other work. --- protocols/jabber/jabber.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'protocols/jabber/jabber.h') diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index c68ae343..0a46633e 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -94,6 +94,7 @@ struct jabber_data char *username; /* USERNAME@server */ char *server; /* username@SERVER -=> server/domain, not hostname */ + const struct oauth2_service *oauth2_service; char *oauth2_access_token; /* After changing one of these two (or the priority setting), call @@ -326,6 +327,10 @@ void sasl_oauth2_init( struct im_connection *ic ); int sasl_oauth2_get_refresh_token( struct im_connection *ic, const char *msg ); int sasl_oauth2_refresh( struct im_connection *ic, const char *refresh_token ); +extern const struct oauth2_service oauth2_service_google; +extern const struct oauth2_service oauth2_service_facebook; +extern const struct oauth2_service oauth2_service_mslive; + /* conference.c */ struct groupchat *jabber_chat_join( struct im_connection *ic, const char *room, const char *nick, const char *password ); struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name ); -- cgit v1.2.3 From 64b663524a465efb7707a2c634be97b9fb6f963b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 18 Dec 2011 22:56:44 +0100 Subject: Restructured and updated code a little bit to support new-style (much better and "proper" OAuth2) Facebook OAuth support. (And, add wl.offline scope to get tokens that don't expire after an hour.) --- protocols/jabber/jabber.h | 1 + 1 file changed, 1 insertion(+) (limited to 'protocols/jabber/jabber.h') diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 0a46633e..57f01695 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -326,6 +326,7 @@ gboolean sasl_supported( struct im_connection *ic ); void sasl_oauth2_init( struct im_connection *ic ); int sasl_oauth2_get_refresh_token( struct im_connection *ic, const char *msg ); int sasl_oauth2_refresh( struct im_connection *ic, const char *refresh_token ); +int sasl_oauth2_load_access_token( struct im_connection *ic ); extern const struct oauth2_service oauth2_service_google; extern const struct oauth2_service oauth2_service_facebook; -- cgit v1.2.3 From 68286eb08dbb6c2aad555f155da6f16ee6f061e8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 20 Dec 2011 17:45:53 +0100 Subject: Detect JID changes at login time and warn the user about them. --- protocols/jabber/jabber.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'protocols/jabber/jabber.h') diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 57f01695..85bcfafe 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -93,6 +93,7 @@ struct jabber_data char *username; /* USERNAME@server */ char *server; /* username@SERVER -=> server/domain, not hostname */ + char *me; /* bare jid */ const struct oauth2_service *oauth2_service; char *oauth2_access_token; @@ -307,6 +308,7 @@ void jabber_buddy_remove_all( struct im_connection *ic ); time_t jabber_get_timestamp( struct xt_node *xt ); struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns ); void jabber_error_free( struct jabber_error *err ); +gboolean jabber_set_me( struct im_connection *ic, const char *me ); extern const struct jabber_away_state jabber_away_state_list[]; -- cgit v1.2.3 From e14b47b826594772e4f3d0dbec1bf17153aa92b1 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 21 Dec 2011 11:48:08 +0100 Subject: Fix parsing of acc->pass. Use oauth_params_ functions instead of string magic, fixes escaping issues. --- protocols/jabber/jabber.h | 1 - 1 file changed, 1 deletion(-) (limited to 'protocols/jabber/jabber.h') diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 85bcfafe..49cfe8ee 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -328,7 +328,6 @@ gboolean sasl_supported( struct im_connection *ic ); void sasl_oauth2_init( struct im_connection *ic ); int sasl_oauth2_get_refresh_token( struct im_connection *ic, const char *msg ); int sasl_oauth2_refresh( struct im_connection *ic, const char *refresh_token ); -int sasl_oauth2_load_access_token( struct im_connection *ic ); extern const struct oauth2_service oauth2_service_google; extern const struct oauth2_service oauth2_service_facebook; -- cgit v1.2.3 From 34ded90e19635c7ebf2afd184f36b03abc879bec Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 24 Dec 2011 19:09:05 +0100 Subject: Slight cleanup: Use a constant instead of just "jabber_oauth" everywhere, and added some safeguards to keep the user from messaging it when we're not actually doing OAuth setup. --- protocols/jabber/jabber.h | 1 + 1 file changed, 1 insertion(+) (limited to 'protocols/jabber/jabber.h') diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 76546bde..046741a3 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -193,6 +193,7 @@ struct jabber_transfer }; #define JABBER_XMLCONSOLE_HANDLE "xmlconsole" +#define JABBER_OAUTH_HANDLE "jabber_oauth" /* Prefixes to use for packet IDs (mainly for IQ packets ATM). Usually the first one should be used, but when storing a packet in the cache, a -- cgit v1.2.3