summaryrefslogtreecommitdiff
path: root/imap/src
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2020-01-15 12:42:06 -0700
committerEduardo Chappa <chappa@washington.edu>2020-01-15 12:42:06 -0700
commit9822842646bc2b940d4b98a260ee4e3ac26fce57 (patch)
tree9d468eb7a6d6b3a41c6c8cd7d542009cb498bc5b /imap/src
parent36fcd566e99d76543c28ce985fc71e8a7cfb6c83 (diff)
downloadalpine-9822842646bc2b940d4b98a260ee4e3ac26fce57.tar.xz
* Add configuration screen for XOAUTH, so users can configure their own
client-id and client-secret information.
Diffstat (limited to 'imap/src')
-rw-r--r--imap/src/c-client/auth_oa2.c16
-rw-r--r--imap/src/c-client/mail.c7
-rw-r--r--imap/src/c-client/mail.h8
3 files changed, 22 insertions, 9 deletions
diff --git a/imap/src/c-client/auth_oa2.c b/imap/src/c-client/auth_oa2.c
index 907f722f..7ac1cb23 100644
--- a/imap/src/c-client/auth_oa2.c
+++ b/imap/src/c-client/auth_oa2.c
@@ -228,15 +228,17 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user,
char *s = NULL;
JSON_S *json = NULL;
- if(oauth2->param[OA2_Id].value == NULL
- || oauth2->param[OA2_Secret].value == NULL){
- /*
- * We need to implement client-side entering client_id and
- * client_secret, and other parameters. In the mean time, bail out.
- */
- return;
+ if(oauth2->param[OA2_Id].value == NULL || oauth2->param[OA2_Secret].value == NULL){
+ oauth2clientinfo_t ogci =
+ (oauth2clientinfo_t) mail_parameters (NIL, GET_OA2CLIENTINFO, NIL);
+
+ if(ogci) (*ogci)(oauth2->name, &oauth2->param[OA2_Id].value,
+ &oauth2->param[OA2_Secret].value);
}
+ if(oauth2->param[OA2_Id].value == NULL || oauth2->param[OA2_Secret].value == NULL)
+ return;
+
/* first check if we have a refresh token, and in that case use it */
if(oauth2->param[OA2_RefreshToken].value){
diff --git a/imap/src/c-client/mail.c b/imap/src/c-client/mail.c
index 7291a642..adddb9d4 100644
--- a/imap/src/c-client/mail.c
+++ b/imap/src/c-client/mail.c
@@ -91,6 +91,8 @@ static copyuid_t mailcopyuid = NIL;
static appenduid_t mailappenduid = NIL;
static oauth2getaccesscode_t oauth2getaccesscode = NIL;
+
+static oauth2clientinfo_t oauth2clientinfo = NIL;
/* free elt extra stuff callback */
static freeeltsparep_t mailfreeeltsparep = NIL;
/* free envelope extra stuff callback */
@@ -673,6 +675,11 @@ void *mail_parameters (MAILSTREAM *stream,long function,void *value)
case GET_OA2CLIENTGETACCESSCODE:
ret = (void *) oauth2getaccesscode;
break;
+ case SET_OA2CLIENTINFO:
+ oauth2clientinfo = (oauth2clientinfo_t) value;
+ case GET_OA2CLIENTINFO:
+ ret = (void *) oauth2clientinfo;
+ break;
default:
if ((r = smtp_parameters (function,value)) != NULL) ret = r;
if ((r = env_parameters (function,value)) != NULL) ret = r;
diff --git a/imap/src/c-client/mail.h b/imap/src/c-client/mail.h
index b5cd65d2..4cb35133 100644
--- a/imap/src/c-client/mail.h
+++ b/imap/src/c-client/mail.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2018 Eduardo Chappa
+ * Copyright 2016-2020 Eduardo Chappa
*
* Last Edited: July 21, 2018 Eduardo Chappa <chappa@washington.edu>
*
@@ -156,6 +156,8 @@
#define SET_IDSTREAM (long) 168
#define GET_OA2CLIENTGETACCESSCODE (long) 169
#define SET_OA2CLIENTGETACCESSCODE (long) 170
+#define GET_OA2CLIENTINFO (long) 171
+#define SET_OA2CLIENTINFO (long) 172
/* 2xx: environment */
#define GET_USERNAME (long) 201
@@ -1939,7 +1941,7 @@ typedef struct OA2_serverparam_s {
} OAUTH2_SERVER_METHOD_S;
typedef struct oauth2_s {
- char *name; /* provider name */
+ unsigned char *name; /* provider name */
char *host[OAUTH2_TOT_EQUIV]; /* servers for which this data applies */
OAUTH2_PARAM_S param[OA2_End]; /* parameters name and values for this server */
/* servers, methods and parameters to retrieve access code and tokens */
@@ -1949,3 +1951,5 @@ typedef struct oauth2_s {
} OAUTH2_S;
typedef char *(*oauth2getaccesscode_t) (char *url, OAUTH2_S *, int *);
+typedef void *(*oauth2clientinfo_t)(char *name, char **id, char **secret);
+