Changeset e1c926f
- Timestamp:
- 2011-07-31T15:44:37Z (13 years ago)
- Branches:
- master
- Children:
- f138bd2
- Parents:
- 39a939c
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/md5.c
r39a939c re1c926f 24 24 #include <sys/types.h> 25 25 #include <string.h> /* for memcpy() */ 26 #include <stdio.h> 26 27 #include "md5.h" 27 28 -
protocols/jabber/jabber.h
r39a939c re1c926f 47 47 JFLAG_XMLCONSOLE = 64, /* If the user added an xmlconsole buddy. */ 48 48 JFLAG_STARTTLS_DONE = 128, /* If a plaintext session was converted to TLS. */ 49 50 JFLAG_SASL_FB = 0x10000, /* Trying Facebook authentication. */ 49 51 } jabber_flags_t; 50 52 -
protocols/jabber/sasl.c
r39a939c re1c926f 27 27 #include "base64.h" 28 28 #include "oauth2.h" 29 #include "oauth.h" 29 30 30 31 xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data ) … … 34 35 struct xt_node *c, *reply; 35 36 char *s; 36 int sup_plain = 0, sup_digest = 0, sup_oauth2 = 0 ;37 int sup_plain = 0, sup_digest = 0, sup_oauth2 = 0, sup_fb = 0; 37 38 38 39 if( !sasl_supported( ic ) ) … … 62 63 if( c->text && g_strcasecmp( c->text, "X-OAUTH2" ) == 0 ) 63 64 sup_oauth2 = 1; 65 if( c->text && g_strcasecmp( c->text, "X-FACEBOOK-PLATFORM" ) == 0 ) 66 sup_fb = 1; 64 67 65 68 c = c->next; … … 101 104 reply->text_len = strlen( reply->text ); 102 105 g_free( s ); 106 } 107 else if( sup_fb && strstr( ic->acc->pass, "session_key=" ) ) 108 { 109 xt_add_attr( reply, "mechanism", "X-FACEBOOK-PLATFORM" ); 110 jd->flags |= JFLAG_SASL_FB; 103 111 } 104 112 else if( sup_digest ) … … 239 247 dec = frombase64( node->text ); 240 248 241 if( !( s = sasl_get_part( dec, "rspauth" ) ) ) 249 if( jd->flags & JFLAG_SASL_FB ) 250 { 251 GSList *p_in = NULL, *p_out = NULL, *p; 252 md5_state_t md5; 253 char time[33], *fmt, *token; 254 const char *secret; 255 256 oauth_params_parse( &p_in, dec ); 257 oauth_params_add( &p_out, "nonce", oauth_params_get( &p_in, "nonce" ) ); 258 oauth_params_add( &p_out, "method", oauth_params_get( &p_in, "method" ) ); 259 oauth_params_free( &p_in ); 260 261 token = g_strdup( ic->acc->pass ); 262 oauth_params_parse( &p_in, token ); 263 g_free( token ); 264 oauth_params_add( &p_out, "session_key", oauth_params_get( &p_in, "session_key" ) ); 265 266 g_snprintf( time, sizeof( time ), "%lld", (long long) ( gettime() * 1000 ) ); 267 oauth_params_add( &p_out, "call_id", time ); 268 oauth_params_add( &p_out, "api_key", oauth2_service_facebook.consumer_key ); 269 oauth_params_add( &p_out, "v", "1.0" ); 270 oauth_params_add( &p_out, "format", "XML" ); 271 272 md5_init( &md5 ); 273 for( p = p_out; p; p = p->next ) 274 md5_append( &md5, p->data, strlen( p->data ) ); 275 276 secret = oauth_params_get( &p_in, "secret" ); 277 md5_append( &md5, (unsigned char*) secret, strlen( secret ) ); 278 md5_finish_ascii( &md5, time ); 279 oauth_params_add( &p_out, "sig", time ); 280 281 fmt = oauth_params_string( p_out ); 282 oauth_params_free( &p_out ); 283 oauth_params_free( &p_in ); 284 s = tobase64( fmt ); 285 g_free( fmt ); 286 } 287 else if( !( s = sasl_get_part( dec, "rspauth" ) ) ) 242 288 { 243 289 /* See RFC 2831 for for information. */ … … 445 491 imcb_error( ic, "OAuth failure (missing access token)" ); 446 492 imc_logout( ic, TRUE ); 493 return; 447 494 } 448 495 if( refresh_token != NULL )
Note: See TracChangeset
for help on using the changeset viewer.