mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-06-20 22:09:00 -04:00
add defensive code on policy checks
This commit is contained in:
@@ -6,9 +6,13 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-proxy/pkg/config"
|
||||
)
|
||||
|
||||
// initialize a local logger instance
|
||||
var logger = log.NewLogger()
|
||||
|
||||
// MultiHostReverseProxy extends httputil to support multiple hosts with diffent policies
|
||||
type MultiHostReverseProxy struct {
|
||||
httputil.ReverseProxy
|
||||
@@ -67,8 +71,14 @@ func (p *MultiHostReverseProxy) AddHost(policy string, target *url.URL, endpoint
|
||||
|
||||
func (p *MultiHostReverseProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO need to fetch from the accounts service
|
||||
policy := "reva"
|
||||
var hit bool
|
||||
policy := "reva"
|
||||
|
||||
if _, ok := p.Directors[policy]; !ok {
|
||||
logger.
|
||||
Error().
|
||||
Msgf("policy %v is not configured", policy)
|
||||
}
|
||||
|
||||
for k := range p.Directors[policy] {
|
||||
if strings.HasPrefix(r.URL.Path, k) && k != "/" {
|
||||
|
||||
Reference in New Issue
Block a user