mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 05:52:51 +00:00
* 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]>
45 lines
992 B
Go
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)
|
|
}
|