do not try to add the selected policy to the context

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2021-07-14 20:45:38 +00:00
parent 85693de589
commit 8c7f1f01ff
6 changed files with 9 additions and 19 deletions
-2
View File
@@ -6,7 +6,6 @@ import (
"github.com/go-chi/chi/middleware"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/proxy/pkg/proxy/policy"
)
// AccessLog is a middleware to log http requests at info level logging.
@@ -22,7 +21,6 @@ func AccessLog(logger log.Logger) func(http.Handler) http.Handler {
Str("request", r.Header.Get("X-Request-ID")).
Str("remote-addr", r.RemoteAddr).
Str("method", r.Method).
Str("routing-policy", policy.ContextGetPolicy(r.Context())).
Int("status", wrap.Status()).
Str("path", r.URL.Path).
Dur("duration", time.Since(start)).
+1
View File
@@ -96,6 +96,7 @@ func (m oidcAuth) getClaims(token string, req *http.Request) (claims oidc.Standa
return
}
// TODO allow extracting arbitrary claims ... or require idp to send a specific claim
if err := userInfo.Claims(&claims); err != nil {
m.logger.Error().Err(err).Interface("userinfo", userInfo).Msg("failed to unmarshal userinfo claims")
status = http.StatusInternalServerError
-14
View File
@@ -20,20 +20,6 @@ var (
ErrUnexpectedConfigError = fmt.Errorf("could not initialize policy-selector for given config")
)
// policyKey serves as key for the routing policy in the context
var policyKey struct{}
// ContextGetPolicy returns the policy if set in the given context.
func ContextGetPolicy(ctx context.Context) string {
u, _ := ctx.Value(policyKey).(string)
return u
}
// ContextSetPolicy stores the selected policy in the context.
func ContextSetPolicy(ctx context.Context, p string) context.Context {
return context.WithValue(ctx, policyKey, p)
}
// Selector is a function which selects a proxy-policy based on the request.
//
// A policy is a random name which identifies a set of proxy-routes:
-1
View File
@@ -146,7 +146,6 @@ func (p *MultiHostReverseProxy) directorSelectionDirector(r *http.Request) {
Str("routeType", string(rt)).
Msg("director found")
r = r.WithContext(policy.ContextSetPolicy(r.Context(), pol))
p.Directors[pol][rt][endpoint](r)
return
}