From a62803f932771516ca05a17167b63d1310ce3611 Mon Sep 17 00:00:00 2001 From: Mike Crute Date: Sun, 21 Nov 2021 20:55:07 -0800 Subject: Extract URL router interface --- app/middleware/auth.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/middleware/auth.go b/app/middleware/auth.go index a88313c..58b10a7 100644 --- a/app/middleware/auth.go +++ b/app/middleware/auth.go @@ -11,6 +11,7 @@ import ( "code.crute.us/mcrute/cloud-identity-broker/auth" "code.crute.us/mcrute/cloud-identity-broker/auth/github" + glecho "code.crute.us/mcrute/golib/echo" "github.com/labstack/echo/v4" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" @@ -25,13 +26,6 @@ var apiKeyRequests = promauto.NewCounterVec(prometheus.CounterOpts{ Help: "Total number of requests using the X-API-Key header", }, nil) -// canRegisterUrls is an interface that identifies what about an HTTP router is -// needed by this middleware. This mainly exists to work around the fact that -// our server is actually a golib.EchoWrapper and not an echo.Echo. -type canRegisterUrls interface { - GET(string, echo.HandlerFunc, ...echo.MiddlewareFunc) *echo.Route -} - const ( authPrincipalContextKey = "broker.AuthorizedPrincipal" gitHubTokenCookie = "github-token" @@ -85,7 +79,7 @@ func (m *AuthenticationMiddleware) redirectToGitHubAuth(c echo.Context) error { // This is here instead of in the web main because these paths are encoded in // the configuration for the GitHub application so changing them requires // addition changes to that configuration. -func (m *AuthenticationMiddleware) RegisterUrls(e canRegisterUrls) { +func (m *AuthenticationMiddleware) RegisterUrls(e glecho.URLRouter) { e.GET(oauthReturnUrl, m.HandleCompleteLogin) } -- cgit v1.2.3