diff options
author | Eduardo Chappa <chappa@washington.edu> | 2021-11-01 20:42:12 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2021-11-01 20:42:12 -0600 |
commit | a0159a2dc04389a62d81f39d91f76cfab6b7293c (patch) | |
tree | 8fdc4cd5db688294e6567639d3876386a28dbdce /imap | |
parent | e90e7ba5b8e93f47d5e4a3f2afa1748246b079e6 (diff) | |
download | alpine-a0159a2dc04389a62d81f39d91f76cfab6b7293c.tar.xz |
* When Alpine is trying to decide which client-id to choose it used to limit
its choices the ps_global->vars[V_XOAUTH2_INFO].current_val.l. Now it will
also use ps_global->vars[V_XOAUTH2_INFO].main_user_val.l. In addition some
of the code in alpine/xoauth2conf.c was moved to the c-client library.
Diffstat (limited to 'imap')
-rw-r--r-- | imap/src/c-client/mail.h | 3 | ||||
-rw-r--r-- | imap/src/c-client/oauth2_aux.c | 42 |
2 files changed, 39 insertions, 6 deletions
diff --git a/imap/src/c-client/mail.h b/imap/src/c-client/mail.h index 8e848201..94ac64fa 100644 --- a/imap/src/c-client/mail.h +++ b/imap/src/c-client/mail.h @@ -2034,6 +2034,9 @@ char *oauth2_generate_state(void); void oauth2deviceinfo_get_accesscode(void *, void *); XOAUTH2_INFO_S *new_xoauth2_info(void); void free_xoauth2_info(XOAUTH2_INFO_S **); +void free_xoauth2_info_list(XOAUTH2_INFO_S ***); XOAUTH2_INFO_S *copy_xoauth2_info(XOAUTH2_INFO_S *); +int same_xoauth2_info(XOAUTH2_INFO_S, XOAUTH2_INFO_S); char *oauth2_generate_state(void); void renew_accesstoken(MAILSTREAM *); +XOAUTH2_INFO_S **parse_xoauth2_info_list(char **, int *); diff --git a/imap/src/c-client/oauth2_aux.c b/imap/src/c-client/oauth2_aux.c index a0828ba4..363f41d1 100644 --- a/imap/src/c-client/oauth2_aux.c +++ b/imap/src/c-client/oauth2_aux.c @@ -65,7 +65,8 @@ char *xoauth2_server(char *, char *); (Y)[i].name = (Y)[i].value = NULL; \ } -char *xoauth2_server(char *server, char *tenant) +char * +xoauth2_server(char *server, char *tenant) { char *rv = NULL; char *s; @@ -100,7 +101,8 @@ char *xoauth2_server(char *server, char *tenant) return rv; } -JSON_S *oauth2_json_reply(OAUTH2_SERVER_METHOD_S RefreshMethod, OAUTH2_S *oauth2, int *status) +JSON_S * +oauth2_json_reply(OAUTH2_SERVER_METHOD_S RefreshMethod, OAUTH2_S *oauth2, int *status) { JSON_S *json = NULL; HTTP_PARAM_S params[OAUTH2_PARAM_NUMBER]; @@ -312,7 +314,8 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method, } } -void oauth2deviceinfo_get_accesscode(void *inp, void *outp) +void +oauth2deviceinfo_get_accesscode(void *inp, void *outp) { OAUTH2_DEVICEPROC_S *oad = (OAUTH2_DEVICEPROC_S *) inp; OAUTH2_S *oauth2 = oad->xoauth2; @@ -380,14 +383,16 @@ void oauth2deviceinfo_get_accesscode(void *inp, void *outp) *(int *)outp = rv; } -XOAUTH2_INFO_S *new_xoauth2_info(void) +XOAUTH2_INFO_S * +new_xoauth2_info(void) { XOAUTH2_INFO_S *rv = fs_get(sizeof(XOAUTH2_INFO_S)); memset((void *) rv, 0, sizeof(XOAUTH2_INFO_S)); return rv; } -void free_xoauth2_info(XOAUTH2_INFO_S **xp) +void +free_xoauth2_info(XOAUTH2_INFO_S **xp) { if(xp == NULL || *xp == NULL) return; @@ -400,7 +405,8 @@ void free_xoauth2_info(XOAUTH2_INFO_S **xp) fs_give((void **) xp); } -XOAUTH2_INFO_S *copy_xoauth2_info(XOAUTH2_INFO_S *x) +XOAUTH2_INFO_S * +copy_xoauth2_info(XOAUTH2_INFO_S *x) { XOAUTH2_INFO_S *y; @@ -415,6 +421,30 @@ XOAUTH2_INFO_S *copy_xoauth2_info(XOAUTH2_INFO_S *x) return y; } +int +same_xoauth2_info(XOAUTH2_INFO_S x, XOAUTH2_INFO_S y) +{ + int rv = 0; + if(x.name && y.name && !strcmp((char *) x.name, (char *) y.name) + && x.client_id && y.client_id && !strcmp(x.client_id, y.client_id) + && ((!x.client_secret && !y.client_secret) + || (x.client_secret && y.client_secret && !strcmp(x.client_secret, y.client_secret))) + && ((!x.tenant && !y.tenant) || (x.tenant && y.tenant && !strcmp(x.tenant, y.tenant)))) + rv = 1; + return rv; +} + +void +free_xoauth2_info_list(XOAUTH2_INFO_S ***xp) +{ + int i; + + if(xp == NULL || *xp == NULL || **xp) return; + for(i = 0; (*xp)[i] != NULL; i++) free_xoauth2_info(&(*xp)[i]); + fs_give((void **) &xp); +} + + /* This function does not create a refresh token and and * an access token, but uses an already known refresh token * to generate a refresh token on an ALREADY OPEN stream. |