diff options
Diffstat (limited to 'app/middleware')
-rw-r--r-- | app/middleware/auth.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/middleware/auth.go b/app/middleware/auth.go index 167d261..0a20a9e 100644 --- a/app/middleware/auth.go +++ b/app/middleware/auth.go | |||
@@ -12,8 +12,19 @@ import ( | |||
12 | "code.crute.us/mcrute/cloud-identity-broker/auth/github" | 12 | "code.crute.us/mcrute/cloud-identity-broker/auth/github" |
13 | 13 | ||
14 | "github.com/labstack/echo/v4" | 14 | "github.com/labstack/echo/v4" |
15 | "github.com/prometheus/client_golang/prometheus" | ||
16 | "github.com/prometheus/client_golang/prometheus/promauto" | ||
15 | ) | 17 | ) |
16 | 18 | ||
19 | // apiKeyRequests tracks the number of requests made with the legacy X-API-Key | ||
20 | // header instead of the Authorization header so that we can track when it's | ||
21 | // safe to remove that edge-case. | ||
22 | var apiKeyRequests = promauto.NewCounterVec(prometheus.CounterOpts{ | ||
23 | Namespace: "aws_access", // Legacy Namespace | ||
24 | Name: "api_key_request_total", | ||
25 | Help: "Total number of requests using the X-API-Key header", | ||
26 | }, nil) | ||
27 | |||
17 | // canRegisterUrls is an interface that identifies what about an HTTP router is | 28 | // canRegisterUrls is an interface that identifies what about an HTTP router is |
18 | // needed by this middleware. This mainly exists to work around the fact that | 29 | // needed by this middleware. This mainly exists to work around the fact that |
19 | // our server is actually a golib.EchoWrapper and not an echo.Echo. | 30 | // our server is actually a golib.EchoWrapper and not an echo.Echo. |
@@ -106,6 +117,8 @@ func (m *AuthenticationMiddleware) Middleware(next echo.HandlerFunc) echo.Handle | |||
106 | if len(tp) == 2 && tp[0] == "Bearer" { | 117 | if len(tp) == 2 && tp[0] == "Bearer" { |
107 | token = tp[1] | 118 | token = tp[1] |
108 | } | 119 | } |
120 | } else { | ||
121 | apiKeyRequests.With(nil).Inc() | ||
109 | } | 122 | } |
110 | 123 | ||
111 | // If an API key is specified this is a success or failure path. There | 124 | // If an API key is specified this is a success or failure path. There |