frontend config for interstitial enable/disable; zrok.proxy.v1 support for interstitial enablement (#704)

This commit is contained in:
Michael Quigley 2024-07-24 10:43:22 -04:00
parent b7423ca59e
commit 2e3d6a627f
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 20 additions and 15 deletions

View File

@ -12,12 +12,13 @@ import (
const V = 3 const V = 3
type Config struct { type Config struct {
V int V int
Identity string Identity string
Address string Address string
HostMatch string HostMatch string
Oauth *OauthConfig Interstitial bool
Tls *endpoints.TlsConfig Oauth *OauthConfig
Tls *endpoints.TlsConfig
} }
type OauthConfig struct { type OauthConfig struct {
@ -45,8 +46,9 @@ type OauthProviderConfig struct {
func DefaultConfig() *Config { func DefaultConfig() *Config {
return &Config{ return &Config{
Identity: "public", Identity: "public",
Address: "0.0.0.0:8080", Address: "0.0.0.0:8080",
Interstitial: false,
} }
} }

View File

@ -158,13 +158,16 @@ func shareHandler(handler http.Handler, pcfg *Config, key []byte, ctx ziti.Conte
if shrToken != "" { if shrToken != "" {
if svc, found := endpoints.GetRefreshedService(shrToken, ctx); found { if svc, found := endpoints.GetRefreshedService(shrToken, ctx); found {
if cfg, found := svc.Config[sdk.ZrokProxyConfig]; found { if cfg, found := svc.Config[sdk.ZrokProxyConfig]; found {
if pcfg.Interstitial {
ignore := r.Header.Get("zrok_interstitial") if _, istlFound := cfg["interstitial"]; istlFound {
_, zrokOkErr := r.Cookie("zrok_interstitial") skip := r.Header.Get("skip_zrok_interstitial")
if ignore == "" && zrokOkErr != nil { _, zrokOkErr := r.Cookie("zrok_interstitial")
logrus.Infof("forcing interstitial for: %v", r.URL) if skip == "" && zrokOkErr != nil {
interstitialUi.WriteInterstitialAnnounce(w) logrus.Debugf("forcing interstitial for '%v'", r.URL)
return interstitialUi.WriteInterstitialAnnounce(w)
return
}
}
} }
if scheme, found := cfg["auth_scheme"]; found { if scheme, found := cfg["auth_scheme"]; found {