Merge pull request #755 from influxdata/feature/fix-kapacitor-auth
Fix kapacitor auth with basic auth in headerpull/10616/head
commit
23b4316853
|
@ -1,6 +1,8 @@
|
||||||
## v1.1.0 [unreleased]
|
## v1.1.0 [unreleased]
|
||||||
|
|
||||||
### Upcoming Bug Fixes
|
### Upcoming Bug Fixes
|
||||||
|
1. [#755](https://github.com/influxdata/chronograf/pull/755): Fix kapacitor basic auth proxying
|
||||||
|
|
||||||
### Upcoming Features
|
### Upcoming Features
|
||||||
1. [#660](https://github.com/influxdata/chronograf/issues/660): Add option to accept any certificate from InfluxDB.
|
1. [#660](https://github.com/influxdata/chronograf/issues/660): Add option to accept any certificate from InfluxDB.
|
||||||
2. [#733](https://github.com/influxdata/chronograf/pull/733): Add optional Github organization membership checks to authentication
|
2. [#733](https://github.com/influxdata/chronograf/pull/733): Add optional Github organization membership checks to authentication
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -105,13 +106,17 @@ func (h *Service) KapacitorProxy(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if srv.Username != "" && srv.Password != "" {
|
|
||||||
u.User = url.UserPassword(srv.Username, srv.Password)
|
|
||||||
}
|
|
||||||
u.Path = path
|
u.Path = path
|
||||||
|
|
||||||
director := func(req *http.Request) {
|
director := func(req *http.Request) {
|
||||||
req.URL = u
|
req.URL = u
|
||||||
|
// Because we are acting as a proxy, kapacitor needs to have the basic auth information set as
|
||||||
|
// a header directly
|
||||||
|
if srv.Username != "" && srv.Password != "" {
|
||||||
|
auth := "Basic " + srv.Username + ":" + srv.Password
|
||||||
|
header := base64.StdEncoding.EncodeToString([]byte(auth))
|
||||||
|
req.Header.Set("Authorization", header)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
proxy := &httputil.ReverseProxy{
|
proxy := &httputil.ReverseProxy{
|
||||||
Director: director,
|
Director: director,
|
||||||
|
|
Loading…
Reference in New Issue