Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by mail.sr.ht (Postfix) with ESMTPS id 0FD2D400C4 for <~sircmpwn/aerc@lists.sr.ht>; Sun, 13 Oct 2019 18:02:11 +0000 (UTC) Authentication-Results: mail.sr.ht; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nGgxK82o Received: by mail-lf1-f65.google.com with SMTP id u3so10213375lfl.10 for <~sircmpwn/aerc@lists.sr.ht>; Sun, 13 Oct 2019 11:02:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=A1VARBbf3WXKPkKHLc6dRlNoPVNAyjswt4MG1kLO2I4=; b=nGgxK82od6cgMsGRl5yp0oGGC6Gt+Fo6wrK60NSfE6aqY78Fs/zL190jgpFciqz79O rXWTAG4aoHSXjjrjl4YmG84OrTxuaQme+jqKeQLSwPGc9COO/J5H1sxvvZXfcKCsBtGN M6veLDeawkx/x43EyQ0ZqtTo8ixg3zmoD32Z271eLqKQ4Ix3qDbFhn1INsli4qVTZIUN BcziGRNtCEVCV7+FpgU+cHH9UntKcXSS5zPcGvg4cJSs6Xs2NV1qH6g1Mr+y3O2qBC/h e+adYgq+JAyCi08n91QMKZLJuNHoJQQUrP7nB7szyexdAitP9u6ADMZWi/QJDlAgmjMN aBZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=A1VARBbf3WXKPkKHLc6dRlNoPVNAyjswt4MG1kLO2I4=; b=Xu5XylNHjckzu1piRaf1diGvI1ZDLNlwty+qnZ1wep9AOjMwQe5aPmkWuytAmT5+B8 hp64vRYI4m6q9duwV3LA/uD+OZ9UMMjMIc1pa3k/kVOUouNrg9kB0AwX/6AC2ewnXMTy eHTWeFof79mB78Tc09ZypFvf1XuLEJv72VFkFhFW3yWmidO908Hxv8pWvrYgSjKIbrUy J+nTKrYxMTK0viOPKhWVbVJjV3dw0lNjXWRaH2gqFfKy0GFQ9AyRrSK9SYZ4jF9vtWnx g+viUJXY1Ic60ZRQc1la8espfSVOK/8Yhf/DYt+sx0S59k/nROWcdySI8B1a1Ibi17Qm wVgw== X-Gm-Message-State: APjAAAX//YRlowOeU8S/DNZlrE9PqkxKWfI0Lx9pvxUS5v1HugW0OQKj HYbZh201Hf93xJ0KYRrzODals9OB X-Google-Smtp-Source: APXvYqxo01AgFH5l2W0dfnPO9rgqhBE46WmdRI+1G/yfS319SX60hRP/nQJ+As8yTLm1T2Qrgt3VaQ== X-Received: by 2002:a19:6f0e:: with SMTP id k14mr15148948lfc.34.1570989729611; Sun, 13 Oct 2019 11:02:09 -0700 (PDT) Received: from localhost (254.90-149-250.nextgentel.com. [90.149.250.254]) by smtp.gmail.com with ESMTPSA id g3sm3664403ljj.59.2019.10.13.11.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2019 11:02:09 -0700 (PDT) From: Frode Aannevik To: ~sircmpwn/aerc@lists.sr.ht Cc: Frode Aannevik Subject: [PATCH] Fix: oauthbearer runtime error Date: Sun, 13 Oct 2019 20:01:16 +0200 Message-Id: <20191013180115.3635-1-frode.aa@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Configure an oauthbearer source without a token_endpoint parameter would panic due to nil pointer dereference Example source=3Dimaps+oauthbearer://frode.aa%40gmail.com@imap.gmail.com:993 source-cred-cmd=3Dpass oatuh2 frode.aa@gmail.com token_endpoint is not required as it will use the provided password as access_token when it is not set --- worker/imap/worker.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/worker/imap/worker.go b/worker/imap/worker.go index cd63c39..4d3e51c 100644 --- a/worker/imap/worker.go +++ b/worker/imap/worker.go @@ -85,14 +85,15 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMe= ssage) error { w.config.scheme =3D strings.TrimSuffix(w.config.scheme, "+oauthbearer= ") w.config.oauthBearer.Enabled =3D true q :=3D u.Query() + + oauth2 :=3D &oauth2.Config{} if q.Get("token_endpoint") !=3D "" { - w.config.oauthBearer.OAuth2 =3D &oauth2.Config{ - ClientID: q.Get("client_id"), - ClientSecret: q.Get("client_secret"), - Scopes: []string{q.Get("scope")}, - } - w.config.oauthBearer.OAuth2.Endpoint.TokenURL =3D q.Get("token_endpo= int") + oauth2.ClientID =3D q.Get("client_id") + oauth2.ClientSecret =3D q.Get("client_secret") + oauth2.Scopes =3D []string{q.Get("scope")} + oauth2.Endpoint.TokenURL =3D q.Get("token_endpoint") } + w.config.oauthBearer.OAuth2 =3D oauth2 } =20 w.config.addr =3D u.Host --=20 2.20.1