mirror of
https://github.com/openziti/zrok.git
synced 2025-08-16 19:01:16 +02:00
generalized implementation of public/private share (#34)
This commit is contained in:
@ -8,7 +8,7 @@ import (
|
||||
"github.com/openziti/zrok/endpoints/publicProxy/healthUi"
|
||||
"github.com/openziti/zrok/endpoints/publicProxy/notFoundUi"
|
||||
"github.com/openziti/zrok/environment"
|
||||
"github.com/openziti/zrok/model"
|
||||
"github.com/openziti/zrok/sdk"
|
||||
"github.com/openziti/zrok/util"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -38,7 +38,7 @@ func NewHTTP(cfg *Config) (*httpFrontend, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error loading config")
|
||||
}
|
||||
zCfg.ConfigTypes = []string{model.ZrokProxyConfig}
|
||||
zCfg.ConfigTypes = []string{sdk.ZrokProxyConfig}
|
||||
zCtx, err := ziti.NewContext(zCfg)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error loading ziti context")
|
||||
@ -99,7 +99,7 @@ func hostTargetReverseProxy(cfg *Config, ctx ziti.Context) *httputil.ReverseProx
|
||||
director := func(req *http.Request) {
|
||||
targetShrToken := resolveService(cfg.HostMatch, req.Host)
|
||||
if svc, found := endpoints.GetRefreshedService(targetShrToken, ctx); found {
|
||||
if cfg, found := svc.Config[model.ZrokProxyConfig]; found {
|
||||
if cfg, found := svc.Config[sdk.ZrokProxyConfig]; found {
|
||||
logrus.Debugf("auth model: %v", cfg)
|
||||
} else {
|
||||
logrus.Warn("no config!")
|
||||
@ -133,15 +133,15 @@ func authHandler(handler http.Handler, realm string, cfg *Config, ctx ziti.Conte
|
||||
shrToken := resolveService(cfg.HostMatch, r.Host)
|
||||
if shrToken != "" {
|
||||
if svc, found := endpoints.GetRefreshedService(shrToken, ctx); found {
|
||||
if cfg, found := svc.Config[model.ZrokProxyConfig]; found {
|
||||
if cfg, found := svc.Config[sdk.ZrokProxyConfig]; found {
|
||||
if scheme, found := cfg["auth_scheme"]; found {
|
||||
switch scheme {
|
||||
case string(model.None):
|
||||
case string(sdk.None):
|
||||
logrus.Debugf("auth scheme none '%v'", shrToken)
|
||||
handler.ServeHTTP(w, r)
|
||||
return
|
||||
|
||||
case string(model.Basic):
|
||||
case string(sdk.Basic):
|
||||
logrus.Debugf("auth scheme basic '%v", shrToken)
|
||||
inUser, inPass, ok := r.BasicAuth()
|
||||
if !ok {
|
||||
|
Reference in New Issue
Block a user