Ignore:
Timestamp:
2016-08-30T20:40:19Z (4 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
15c4cd4, a33ee0f
Parents:
2dc394c
Message:

hipchat: Add basic support for personal oauth tokens

Fixes trac ticket 1265 - see the comments on that ticket for reasons on
why personal tokens and not the usual oauth flow. TL;DR hipchat doesn't
allow third party apps to own oauth client secrets. Instead, those are
generated when the "addon" is "installed" which requires a flow that is
either impossible or too awkward to use in bitlbee.

So, after giving up on the right way and telling the users to manage
tokens the ugly way, what's left to do is easy, just a few tweaks in the
sasl blob and short-circuit most of the actual oauth stuff. I didn't
even bother changing the service struct from google. It's not used.

This also updates the gtalk SASL X-OAUTH2 code to use GStrings instead of
juggling with malloc/strlen/strcpy, and simplifies a bit the way
GStrings are used in the equivalent SASL PLAIN code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    r2dc394c r67ea361  
    8282        s->flags |= SET_NOSAVE | ACC_SET_OFFLINE_ONLY | SET_NULL_OK;
    8383
     84        set_add(&acc->set, "oauth", "false", set_eval_oauth, acc);
     85
    8486        if (strcmp(acc->prpl->name, "hipchat") == 0) {
    8587                set_setstr(&acc->set, "server", "chat.hipchat.com");
    8688        } else {
    87                 set_add(&acc->set, "oauth", "false", set_eval_oauth, acc);
    88 
    8989                /* this reuses set_eval_oauth, which clears the password */
    9090                set_add(&acc->set, "anonymous", "false", set_eval_oauth, acc);
     
    397397        if (g_strcasecmp(who, JABBER_OAUTH_HANDLE) == 0 &&
    398398            !(jd->flags & OPT_LOGGED_IN) && jd->fd == -1) {
    399                 if (sasl_oauth2_get_refresh_token(ic, message)) {
     399
     400                if (jd->flags & JFLAG_HIPCHAT) {
     401                        sasl_oauth2_got_token(ic, message, NULL, NULL);
     402                        return 1;
     403                } else if (sasl_oauth2_get_refresh_token(ic, message)) {
    400404                        return 1;
    401405                } else {
Note: See TracChangeset for help on using the changeset viewer.