Files
zitadel/internal/denylist/denylist.go
T
8e82ec1cb9 Merge commit from fork
* Add DenyLists parsing

* Remove unneeded returned error

* Plug global denylist into Command

* app creation: apply denylist to backchannel logout URI

* Inject denylist to backchannel logout worker

* webhook config: validate against blocked URLs

* Add notificationsWebhook denylist target

* command: Add SMTP endpoint validation against blocklist

* command: Add SMS endpoint validation against blocklist

* Validate webhook endpoint against denylist on channel notification

* Remove unused tests

* handle deprecated denylists

* remove unintended denylist entry in deprecated list

* use single http client

* fix tests

* update comments

* fixes

* cleanup

* address comments

* fix merge

---------

Co-authored-by: Livio Spring <[email protected]>
2026-06-15 15:36:14 +02:00

45 lines
992 B
Go

package denylist
import (
"net"
"reflect"
"github.com/mitchellh/mapstructure"
)
type AddressChecker interface {
IsDenied([]net.IP, string) error
}
func ParseDenyList(inputList []string) ([]AddressChecker, error) {
var toReturn []AddressChecker
for _, input := range inputList {
parsed := NewHostChecker(input)
if parsed != nil {
toReturn = append(toReturn, parsed)
}
}
return toReturn, nil
}
func DenyListDecodeHook(from, to reflect.Value) (interface{}, error) {
if to.Type() != reflect.TypeFor[[]AddressChecker]() {
return from.Interface(), nil
}
var inputDenyList []string
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
DecodeHook: mapstructure.ComposeDecodeHookFunc(
mapstructure.StringToSliceHookFunc(","),
),
WeaklyTypedInput: true,
Result: &inputDenyList,
})
if err != nil {
return nil, err
}
if err = decoder.Decode(from.Interface()); err != nil {
return nil, err
}
return ParseDenyList(inputDenyList)
}