From 3d880036b2fed34da7d2249f8fd458194a3f466e Mon Sep 17 00:00:00 2001 From: Rohith Jayawardene Date: Tue, 18 Apr 2017 14:48:48 +0200 Subject: [PATCH] Prefix URL Warning (#206) - adding a log warning just to remind its no longer a prefix but a http route --- server.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/server.go b/server.go index 509ba02c..72400dc3 100644 --- a/server.go +++ b/server.go @@ -175,18 +175,19 @@ func (r *oauthProxy) createReverseProxy() error { if err := r.createTemplates(); err != nil { return err } - // step: provision in the protected resources - for _, resource := range r.config.Resources { - log.Infof("protecting resource: %s", resource) - switch resource.WhiteListed { + for _, x := range r.config.Resources { + if x.URL[len(x.URL)-1:] == "/" { + log.Warnf("the resource url: %s is not a prefix, you probably want %s* or %s* to protect the xs", x.URL, x.URL, strings.TrimRight(x.URL, "/")) + } + } + for _, x := range r.config.Resources { + log.Infof("protecting resource: %s", x) + switch x.WhiteListed { case false: - engine.Match(resource.Methods, resource.URL, emptyHandler, - r.authenticationMiddleware(resource), - r.admissionMiddleware(resource), - r.headersMiddleware(r.config.AddClaims)) + engine.Match(x.Methods, x.URL, emptyHandler, r.authenticationMiddleware(x), r.admissionMiddleware(x), r.headersMiddleware(r.config.AddClaims)) default: - engine.Match(resource.Methods, resource.URL, emptyHandler) + engine.Match(x.Methods, x.URL, emptyHandler) } } for name, value := range r.config.MatchClaims {