From 03649e891d07d976af327a2aeed9bbe9fb3abf34 Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Sun, 4 Oct 2020 10:30:27 -0600 Subject: * Addition of XOAUTH2 support for Yahoo!, and update in documentation. --- alpine/imap.c | 44 ++++++++++++++--- alpine/xoauth2.h | 9 +++- alpine/xoauth2conf.c | 9 ++-- pith/pine.hlp | 136 ++++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 180 insertions(+), 18 deletions(-) diff --git a/alpine/imap.c b/alpine/imap.c index b4e044e7..00b5c994 100644 --- a/alpine/imap.c +++ b/alpine/imap.c @@ -241,6 +241,38 @@ OAUTH2_S alpine_oauth2_list[] = 1, /* client secret required */ 0 /* Cancel refresh token */ }, + {YAHOO_NAME, + {"imap.mail.yahoo.com", "smtp.mail.yahoo.com", NULL, NULL}, + {{"client_id", NULL}, + {"client_secret", NULL}, /* used */ + {"tenant", NULL}, /* not used */ + {"code", NULL}, /* used during authorization */ + {"refresh_token", NULL}, + {"scope", NULL}, /* not used! */ + {"redirect_uri", "oob"}, /* https://localhost */ + {"grant_type", "authorization_code"}, + {"grant_type", "refresh_token"}, + {"response_type", "code"}, + {"state", NULL}, /* used */ + {"device_code", NULL} /* not used */ + }, + {{"GET", "https://api.login.yahoo.com/oauth2/request_auth", /* Get Access Code */ + {OA2_Id, OA2_Redirect, OA2_Response, OA2_State, OA2_End, OA2_End, OA2_End}}, + {NULL, NULL, {OA2_End, OA2_End, OA2_End, OA2_End, OA2_End, OA2_End, OA2_End}}, /* device code, not used */ + {"POST", "https://api.login.yahoo.com/oauth2/get_token", /* Get first Refresh Token and Access token */ + {OA2_Id, OA2_Secret, OA2_Redirect, OA2_Code, OA2_GrantTypeforAccessToken, OA2_End, OA2_End}}, + {"POST", "https://api.login.yahoo.com/oauth2/get_token", /* Get access token from refresh token */ + {OA2_Id, OA2_Secret, OA2_Redirect, OA2_RefreshToken, OA2_GrantTypefromRefreshToken, OA2_End, OA2_End}} + }, + {NULL, NULL, NULL, 0, 0, NULL}, /* device_code information, not used */ + NULL, /* access token */ + "ALPINE_V1", /* special IMAP ID */ + 1, /* hide */ + 0, /* expiration time */ + 0, /* first time indicator */ + 1, /* client secret required */ + 0 /* Cancel refresh token */ + }, {YANDEX_NAME, {"imap.yandex.com", "smtp.yandex.com", NULL, NULL}, {{"client_id", NULL}, @@ -3650,8 +3682,8 @@ write_passfile(pinerc, l) char *authend, *authtype; #ifdef WINCRED # if (WINCRED > 0) - char target[4*MAILTMPLEN]; - char blob[4*MAILTMPLEN]; + char target[10*MAILTMPLEN]; + char blob[10*MAILTMPLEN]; CREDENTIAL cred; LPTSTR ltarget = 0; @@ -3701,8 +3733,8 @@ write_passfile(pinerc, l) #elif APPLEKEYCHAIN int rc; - char target[4*MAILTMPLEN]; - char blob[4*MAILTMPLEN]; + char target[10*MAILTMPLEN]; + char blob[10*MAILTMPLEN]; SecKeychainItemRef itemRef = NULL; if(using_passfile == 0) @@ -3769,11 +3801,11 @@ write_passfile(pinerc, l) } #else /* PASSFILE */ - char tmp[4*MAILTMPLEN], blob[4*MAILTMPLEN]; + char tmp[10*MAILTMPLEN], blob[10*MAILTMPLEN]; int i, n; FILE *fp; #ifdef SMIME - char *text = NULL, tmp2[4*MAILTMPLEN]; + char *text = NULL, tmp2[10*MAILTMPLEN]; int len = 0; #endif diff --git a/alpine/xoauth2.h b/alpine/xoauth2.h index 0a17a222..e889078a 100644 --- a/alpine/xoauth2.h +++ b/alpine/xoauth2.h @@ -25,9 +25,14 @@ #define OUTLOOK_SECRET "Tk-DAcEi13-FeSsY_Ja4Y.-MyL66I.wIPt" #define OUTLOOK_TENANT "common" -#define YANDEX_NAME "Yandex" -#define YANDEX_ID "393578fee26f47858023cf59681882a7" +#define YANDEX_NAME "Yandex" +#define YANDEX_ID "393578fee26f47858023cf59681882a7" #define YANDEX_SECRET "7304c4993583498f8ab63e2f21ad6960" #define YANDEX_TENANT NULL +#define YAHOO_NAME "Yahoo!" +#define YAHOO_ID "dj0yJmk9RTdyZEQ2TWxGMzV6JmQ9WVdrOWVrTllZbGgyV2tjbWNHbzlNQT09JnM9Y29uc3VtZXJzZWNyZXQmc3Y9MCZ4PTli" +#define YAHOO_SECRET "3a8b12d51c09b0a5c0733c36d04cd3c69e33baef" +#define YAHOO_TENANT NULL + #endif /* ALPINE_XOAUTH2_INCLUDED */ diff --git a/alpine/xoauth2conf.c b/alpine/xoauth2conf.c index 11c53766..71ecfb32 100644 --- a/alpine/xoauth2conf.c +++ b/alpine/xoauth2conf.c @@ -28,6 +28,7 @@ extern OAUTH2_S alpine_oauth2_list[]; XOAUTH2_INFO_S xoauth_default[] = { { GMAIL_NAME, GMAIL_ID, GMAIL_SECRET, GMAIL_TENANT, NULL, NULL}, { OUTLOOK_NAME, OUTLOOK_ID, OUTLOOK_SECRET, OUTLOOK_TENANT, NULL, NULL}, + { YAHOO_NAME, YAHOO_ID, YAHOO_SECRET, YAHOO_TENANT, NULL, NULL}, { YANDEX_NAME, YANDEX_ID, YANDEX_SECRET, YANDEX_TENANT, NULL, NULL}, { NULL, NULL, NULL, NULL, NULL, NULL} }; @@ -886,7 +887,8 @@ alpine_xoauth2_configuration(struct pine *ps, int edit_exceptions) } if(lval == NULL || lval[k] == NULL){ OAUTH2_S *oa2list; - for(oa2list = alpine_oauth2_list; oa2list; oa2list++){ + for(oa2list = alpine_oauth2_list; oa2list && oa2list->name; oa2list++){ + if(oa2list->hide) continue; if(!strcmp(oa2list->name,xoauth_default[i].name)){ xoauth_default[i].flow = cpystr(oa2list->server_mthd[0].name ? "Authorize" : (oa2list->server_mthd[1].name ? "Device" : "Unknown")); @@ -913,10 +915,11 @@ alpine_xoauth2_configuration(struct pine *ps, int edit_exceptions) y->tenant = cpystr(xoauth_default[i].tenant); for(oa2 = NULL, oa2list = alpine_oauth2_list; oa2 == NULL && oa2list; oa2list++) if(!strcmp(oa2list->name, y->name)) oa2 = oa2list; - if(y->flow == NULL) + if(oa2 && y->flow == NULL) y->flow = cpystr(oa2->server_mthd[0].name ? "Authorize" : (oa2->server_mthd[1].name ? "Device" : "Unknown")); - write_xoauth_conf_entry(y, &xoauth_default[i], &ctmpa, &ctmpb, &first_line, &varlist, &p, ln, k); + if(oa2 && !oa2->hide) + write_xoauth_conf_entry(y, &xoauth_default[i], &ctmpa, &ctmpb, &first_line, &varlist, &p, ln, k); free_xoauth2_info(&y); } } diff --git a/pith/pine.hlp b/pith/pine.hlp index 94a22588..d8370794 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any reasonable place to be called from. Dummy change to get revision in pine.hlp ============= h_revision ================= -Alpine Commit 508 2020-10-03 13:43:20 +Alpine Commit 509 2020-10-04 10:30:23 ============= h_news ================= @@ -191,6 +191,8 @@ problems you find with this release.

Additions include: