chore(gateway): log error on unauthorized attempt (#15452)
parent
f82e6b2626
commit
b3b2f52d57
|
@ -13,6 +13,7 @@
|
||||||
1. [15348](https://github.com/influxdata/influxdb/pull/15348): Disable saving for threshold check if no threshold selected
|
1. [15348](https://github.com/influxdata/influxdb/pull/15348): Disable saving for threshold check if no threshold selected
|
||||||
1. [15354](https://github.com/influxdata/influxdb/pull/15354): Query variable selector shows variable keys, not values
|
1. [15354](https://github.com/influxdata/influxdb/pull/15354): Query variable selector shows variable keys, not values
|
||||||
1. [15246](https://github.com/influxdata/influxdb/pull/15427): UI/Telegraf filter functionality shows results based on input name
|
1. [15246](https://github.com/influxdata/influxdb/pull/15427): UI/Telegraf filter functionality shows results based on input name
|
||||||
|
1. [15452](https://github.com/influxdata/influxdb/pull/15452): Log error as info message on unauthorized API call attempts
|
||||||
|
|
||||||
## v2.0.0-alpha.18 [2019-09-26]
|
## v2.0.0-alpha.18 [2019-09-26]
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,11 @@ func ProbeAuthScheme(r *http.Request) (string, error) {
|
||||||
return sessionAuthScheme, nil
|
return sessionAuthScheme, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *AuthenticationHandler) unauthorized(ctx context.Context, w http.ResponseWriter, err error) {
|
||||||
|
h.Logger.Info("unauthorized", zap.Error(err))
|
||||||
|
UnauthorizedError(ctx, h, w)
|
||||||
|
}
|
||||||
|
|
||||||
// ServeHTTP extracts the session or token from the http request and places the resulting authorizer on the request context.
|
// ServeHTTP extracts the session or token from the http request and places the resulting authorizer on the request context.
|
||||||
func (h *AuthenticationHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *AuthenticationHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
if handler, _, _ := h.noAuthRouter.Lookup(r.Method, r.URL.Path); handler != nil {
|
if handler, _, _ := h.noAuthRouter.Lookup(r.Method, r.URL.Path); handler != nil {
|
||||||
|
@ -79,7 +84,7 @@ func (h *AuthenticationHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
scheme, err := ProbeAuthScheme(r)
|
scheme, err := ProbeAuthScheme(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
UnauthorizedError(ctx, h, w)
|
h.unauthorized(ctx, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,17 +94,17 @@ func (h *AuthenticationHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
|
||||||
case tokenAuthScheme:
|
case tokenAuthScheme:
|
||||||
auth, err = h.extractAuthorization(ctx, r)
|
auth, err = h.extractAuthorization(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
UnauthorizedError(ctx, h, w)
|
h.unauthorized(ctx, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case sessionAuthScheme:
|
case sessionAuthScheme:
|
||||||
auth, err = h.extractSession(ctx, r)
|
auth, err = h.extractSession(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
UnauthorizedError(ctx, h, w)
|
h.unauthorized(ctx, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
UnauthorizedError(ctx, h, w)
|
h.unauthorized(ctx, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue