generalized implementation of public/private share (#34)

This commit is contained in:
Michael Quigley
2023-07-17 16:45:20 -04:00
parent c0503ae593
commit c26d325f61
17 changed files with 153 additions and 76 deletions

View File

@ -7,7 +7,7 @@ import (
"github.com/openziti/zrok/endpoints"
"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"
@ -52,7 +52,7 @@ func NewFrontend(cfg *FrontendConfig) (*Frontend, 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")
@ -121,7 +121,7 @@ func serviceTargetProxy(cfg *FrontendConfig, ctx ziti.Context) *httputil.Reverse
director := func(req *http.Request) {
targetShrToken := cfg.ShrToken
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!")
@ -153,15 +153,15 @@ func serviceTargetProxy(cfg *FrontendConfig, ctx ziti.Context) *httputil.Reverse
func authHandler(shrToken string, handler http.Handler, realm string, cfg *FrontendConfig, ctx ziti.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
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 {