aboutsummaryrefslogtreecommitdiff
path: root/worker/imap/worker.go
diff options
context:
space:
mode:
authorFrode Aannevik <frode.aa@gmail.com>2019-10-13 20:01:16 +0200
committerDrew DeVault <sir@cmpwn.com>2019-10-16 11:04:41 -0400
commit550ef0bc1f21dfaeb1bf216b28c3fce9a816cb73 (patch)
tree066d6f69a9bd408df23d47fb61c9f6cda36304ac /worker/imap/worker.go
parent48a88fe44f617585050e7640a687a82bc5623970 (diff)
Fix: oauthbearer runtime error
Configure an oauthbearer source without a token_endpoint parameter would panic due to nil pointer dereference Example source=imaps+oauthbearer://frode.aa%40gmail.com@imap.gmail.com:993 source-cred-cmd=pass 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
Diffstat (limited to 'worker/imap/worker.go')
-rw-r--r--worker/imap/worker.go13
1 files 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.WorkerMessage) error {
w.config.scheme = strings.TrimSuffix(w.config.scheme, "+oauthbearer")
w.config.oauthBearer.Enabled = true
q := u.Query()
+
+ oauth2 := &oauth2.Config{}
if q.Get("token_endpoint") != "" {
- w.config.oauthBearer.OAuth2 = &oauth2.Config{
- ClientID: q.Get("client_id"),
- ClientSecret: q.Get("client_secret"),
- Scopes: []string{q.Get("scope")},
- }
- w.config.oauthBearer.OAuth2.Endpoint.TokenURL = q.Get("token_endpoint")
+ oauth2.ClientID = q.Get("client_id")
+ oauth2.ClientSecret = q.Get("client_secret")
+ oauth2.Scopes = []string{q.Get("scope")}
+ oauth2.Endpoint.TokenURL = q.Get("token_endpoint")
}
+ w.config.oauthBearer.OAuth2 = oauth2
}
w.config.addr = u.Host