mirror of
https://github.com/nais/wonderwall.git
synced 2026-08-23 21:16:14 +00:00
refactor(url): remove unused field for relative validator
This commit is contained in:
@@ -82,7 +82,7 @@ func NewStandalone(
|
||||
CookieOptions: cookieOpts,
|
||||
Crypter: crypter,
|
||||
Ingresses: ingresses,
|
||||
Redirect: url.NewStandaloneRedirect(ingresses),
|
||||
Redirect: url.NewStandaloneRedirect(),
|
||||
SessionManager: sessionManager,
|
||||
UpstreamProxy: NewReverseProxy(upstream, true),
|
||||
}, nil
|
||||
|
||||
+4
-4
@@ -25,9 +25,9 @@ type StandaloneRedirect struct {
|
||||
*cleaner
|
||||
}
|
||||
|
||||
func NewStandaloneRedirect(ingresses *ingress.Ingresses) *StandaloneRedirect {
|
||||
func NewStandaloneRedirect() *StandaloneRedirect {
|
||||
return &StandaloneRedirect{
|
||||
cleaner: newRelativeCleaner(ingresses.Hosts()),
|
||||
cleaner: newRelativeCleaner(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,9 +142,9 @@ func newAbsoluteCleaner(allowedHosts []string) *cleaner {
|
||||
}
|
||||
}
|
||||
|
||||
func newRelativeCleaner(allowedHosts []string) *cleaner {
|
||||
func newRelativeCleaner() *cleaner {
|
||||
return &cleaner{
|
||||
Validator: NewRelativeValidator(allowedHosts),
|
||||
Validator: NewRelativeValidator(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestDefault(t *testing.T) {
|
||||
}
|
||||
ingresses := mock.Ingresses(cfg)
|
||||
|
||||
h := url.NewStandaloneRedirect(ingresses)
|
||||
h := url.NewStandaloneRedirect()
|
||||
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
|
||||
@@ -60,12 +60,10 @@ func (v *AbsoluteValidator) IsValidRedirect(r *http.Request, redirect string) bo
|
||||
|
||||
var _ Validator = &RelativeValidator{}
|
||||
|
||||
type RelativeValidator struct {
|
||||
allowedDomains []string
|
||||
}
|
||||
type RelativeValidator struct{}
|
||||
|
||||
func NewRelativeValidator(allowedDomains []string) *RelativeValidator {
|
||||
return &RelativeValidator{allowedDomains: allowedDomains}
|
||||
func NewRelativeValidator() *RelativeValidator {
|
||||
return &RelativeValidator{}
|
||||
}
|
||||
|
||||
// IsValidRedirect validates that the given redirect string is a valid relative URL.
|
||||
|
||||
@@ -138,11 +138,7 @@ func TestRelativeValidator_IsValidRedirect(t *testing.T) {
|
||||
ingresses := mock.Ingresses(cfg)
|
||||
r := mock.NewGetRequest("https://wonderwall", ingresses)
|
||||
|
||||
allowedDomains := []string{
|
||||
cfg.SSO.Domain,
|
||||
"www.whitelisteddomain.tld",
|
||||
}
|
||||
relativeValidator := urlpkg.NewRelativeValidator(allowedDomains)
|
||||
relativeValidator := urlpkg.NewRelativeValidator()
|
||||
|
||||
t.Run("open redirects list", func(t *testing.T) {
|
||||
file, err := os.Open("testdata/open-redirects.txt")
|
||||
|
||||
Reference in New Issue
Block a user