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
This commit is contained in:
parent
48a88fe44f
commit
550ef0bc1f
|
@ -85,14 +85,15 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
|
||||||
w.config.scheme = strings.TrimSuffix(w.config.scheme, "+oauthbearer")
|
w.config.scheme = strings.TrimSuffix(w.config.scheme, "+oauthbearer")
|
||||||
w.config.oauthBearer.Enabled = true
|
w.config.oauthBearer.Enabled = true
|
||||||
q := u.Query()
|
q := u.Query()
|
||||||
|
|
||||||
|
oauth2 := &oauth2.Config{}
|
||||||
if q.Get("token_endpoint") != "" {
|
if q.Get("token_endpoint") != "" {
|
||||||
w.config.oauthBearer.OAuth2 = &oauth2.Config{
|
oauth2.ClientID = q.Get("client_id")
|
||||||
ClientID: q.Get("client_id"),
|
oauth2.ClientSecret = q.Get("client_secret")
|
||||||
ClientSecret: q.Get("client_secret"),
|
oauth2.Scopes = []string{q.Get("scope")}
|
||||||
Scopes: []string{q.Get("scope")},
|
oauth2.Endpoint.TokenURL = q.Get("token_endpoint")
|
||||||
}
|
|
||||||
w.config.oauthBearer.OAuth2.Endpoint.TokenURL = q.Get("token_endpoint")
|
|
||||||
}
|
}
|
||||||
|
w.config.oauthBearer.OAuth2 = oauth2
|
||||||
}
|
}
|
||||||
|
|
||||||
w.config.addr = u.Host
|
w.config.addr = u.Host
|
||||||
|
|
Loading…
Reference in New Issue