Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions api/handler/dataflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func (h *DataflowProxyHandler) Proxy(ctx *gin.Context) {
ctx.Abort()
return
}
ctx.Request.Header.Set("user_id", fmt.Sprintf("%d", u.ID))
ctx.Request.Header.Set("user_name", u.Username)
ctx.Request.Header.Set("user_token", token)
ctx.Request.Header.Set("User-Id", fmt.Sprintf("%d", u.ID))
ctx.Request.Header.Set("User-Name", u.Username)
ctx.Request.Header.Set("User-Token", token)
ctx.Request.Header.Set("isadmin", fmt.Sprintf("%t", u.CanAdmin()))
// Log the request URL and header
slog.Debug("http request", slog.Any("request", ctx.Request.URL), slog.Any("header", ctx.Request.Header))
Expand Down
6 changes: 3 additions & 3 deletions api/handler/rproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (r *RProxyHandler) Proxy(ctx *gin.Context) {
return
}
slog.Info("proxy target", slog.Any("appSvcName", appSvcName), slog.Any("target", target),
slog.Any("host", host), slog.Any("apiname", apiname))
slog.Any("set-header-host", host), slog.Any("apiname", apiname))
rp, _ := proxy.NewReverseProxy(target)
if deploy.Type == types.InferenceType || deploy.Type == types.ServerlessType {
// no need context path for inference
Expand Down Expand Up @@ -129,8 +129,8 @@ func (r *RProxyHandler) checkAccessPermission(ctx *gin.Context, deploy *database
}
// check space
allow, err = r.repoComp.AllowAccessByRepoID(ctx.Request.Context(), deploy.RepoID, username)
} else if deploy.ModelID > 0 {
// check model inference
} else {
// check endpoint
allow, err = r.repoComp.AllowAccessEndpoint(ctx.Request.Context(), username, deploy)
}
return allow, err
Expand Down
14 changes: 8 additions & 6 deletions builder/proxy/reverse_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

type ReverseProxy interface {
ServeHTTP(w http.ResponseWriter, r *http.Request, api, host string)
ServeHTTP(w http.ResponseWriter, r *http.Request, api, svcHost string)
}

type reverseProxyImpl struct {
Expand All @@ -29,15 +29,20 @@ func NewReverseProxy(target string) (ReverseProxy, error) {
}, nil
}

func (rp *reverseProxyImpl) ServeHTTP(w http.ResponseWriter, r *http.Request, api, host string) {
func (rp *reverseProxyImpl) ServeHTTP(w http.ResponseWriter, r *http.Request, api, svcHost string) {
defer func() {
if r := recover(); r != nil {
slog.Debug("Connection to target server interrupted", slog.Any("error", r))
}
}()
proxy := httputil.NewSingleHostReverseProxy(rp.target)
proxy.Director = func(req *http.Request) {
req.Host = rp.target.Host
if len(svcHost) > 0 {
slog.Info("update reverse proxy header host", slog.Any("svc-host", svcHost))
req.Host = svcHost
} else {
req.Host = rp.target.Host
}
req.URL.Host = rp.target.Host
req.URL.Scheme = rp.target.Scheme
if len(api) > 0 {
Expand All @@ -46,9 +51,6 @@ func (rp *reverseProxyImpl) ServeHTTP(w http.ResponseWriter, r *http.Request, ap
}
// dont support br comporession
req.Header.Set("Accept-Encoding", "gzip")
if len(host) > 0 {
req.Header.Set("Host", host)
}

// debug only
// {
Expand Down
31 changes: 17 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/looplab/fsm v1.0.3
github.com/marcboeker/go-duckdb v1.5.6
github.com/mcuadros/go-defaults v1.2.0
github.com/minio/minio-go/v7 v7.0.84
github.com/minio/minio-go/v7 v7.0.89
github.com/minio/sha256-simd v1.0.1
github.com/naoina/toml v0.1.1
github.com/nicksnyder/go-i18n/v2 v2.6.0
Expand All @@ -42,8 +42,8 @@ require (
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
github.com/samber/slog-multi v1.3.3
github.com/sethvargo/go-envconfig v1.1.0
github.com/spf13/cast v1.7.0
github.com/spf13/cobra v1.8.1
github.com/spf13/cast v1.7.1
github.com/spf13/cobra v1.9.1
github.com/stretchr/testify v1.10.0
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
Expand Down Expand Up @@ -78,7 +78,7 @@ require (
go.temporal.io/sdk v1.34.0
go.temporal.io/sdk/contrib/opentelemetry v0.6.0
go.temporal.io/server v1.27.2
google.golang.org/grpc v1.71.0
google.golang.org/grpc v1.71.1
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
Expand All @@ -99,9 +99,9 @@ require (
cloud.google.com/go/storage v1.51.0 // indirect
cloud.google.com/go/trace v1.11.3 // indirect
contrib.go.opencensus.io/exporter/stackdriver v0.13.14 // indirect
dario.cat/mergo v1.0.0 // indirect
dario.cat/mergo v1.0.1 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/DataDog/datadog-go v4.4.0+incompatible // indirect
github.com/DataDog/sketches-go v1.0.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0 // indirect
Expand All @@ -128,6 +128,7 @@ require (
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/cli-docs-tool v0.10.0 // indirect
github.com/docker/docker v27.1.1+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
Expand All @@ -142,7 +143,7 @@ require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-sql-driver/mysql v1.9.1 // indirect
github.com/gocql/gocql v1.7.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/google/s2a-go v0.1.9 // indirect
Expand Down Expand Up @@ -171,6 +172,7 @@ require (
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/minio/crc64nvme v1.0.1 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
Expand Down Expand Up @@ -253,6 +255,7 @@ require (
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
gopkg.in/validator.v2 v2.0.1 // indirect
modernc.org/gc/v3 v3.0.0 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
)

require (
Expand All @@ -264,7 +267,7 @@ require (
github.com/alibabacloud-go/openapi-util v0.1.1 // indirect
github.com/alibabacloud-go/tea-utils/v2 v2.0.7
github.com/aliyun/credentials-go v1.4.5
github.com/argoproj/argo-workflows/v3 v3.5.13
github.com/argoproj/argo-workflows/v3 v3.6.12
github.com/blendle/zapdriver v1.3.1 // indirect
github.com/bwmarrin/snowflake v0.3.0
github.com/bytedance/sonic v1.12.5 // indirect
Expand All @@ -290,13 +293,13 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.23.0
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/goccy/go-json v0.10.4 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gnostic-models v0.6.9 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-containerregistry v0.16.1 // indirect
github.com/google/go-containerregistry v0.20.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0
github.com/gorilla/context v1.1.1 // indirect
Expand All @@ -311,7 +314,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
Expand All @@ -330,7 +333,7 @@ require (
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/sirupsen/logrus v1.9.3
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/stripe/stripe-go/v82 v82.3.0
github.com/tjfoc/gmsm v1.4.1 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
Expand All @@ -356,7 +359,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
k8s.io/utils v0.0.0-20241210054802-24370beab758
knative.dev/networking v0.0.0-20241022012959-60e29ff520dc // indirect
knative.dev/pkg v0.0.0-20241021183759-9b9d535af5ad // indirect
Expand Down
Loading
Loading