mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 05:52:51 +00:00
* Inject DenyList from config to `StartCommands()` * Implementation draft * Move address checker to separate package * Migrate usages of actions.AddressChecker to denylist.AddressChecker * Rename denylist package files * Pass []denylist.AddressChecker to StartCommand * Add DenyList to defaults.yaml and add custom config parser * net: add HostnameToIPList function * denylist: Add IsHostBlocked() * actions: use denylist.IsHostBlocked() * command: Inject ip lookup function + extend add target validationt test * command: Unexport ChangeTarget.IsValid() * command: Add denyList check on ChangeTarget validation * command: Export ActionsV2DenyList and IPLookupFunction params * Lint fix * Check denylist during action execution * Fix integration tests * Apply suggestions * Add `mapstructure.StringToSliceHookFunc()` to decode `HTTPConfigDecodeHook`
27 lines
534 B
Go
27 lines
534 B
Go
package denylist
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
type AddressDeniedError struct {
|
|
deniedBy string
|
|
}
|
|
|
|
func NewAddressDeniedError(deniedBy string) *AddressDeniedError {
|
|
return &AddressDeniedError{deniedBy: deniedBy}
|
|
}
|
|
|
|
func (e *AddressDeniedError) Error() string {
|
|
return fmt.Sprintf("address is denied by '%s'", e.deniedBy)
|
|
}
|
|
|
|
func (e *AddressDeniedError) Is(target error) bool {
|
|
var addressDeniedErr *AddressDeniedError
|
|
if !errors.As(target, &addressDeniedErr) {
|
|
return false
|
|
}
|
|
return e.deniedBy == addressDeniedErr.deniedBy
|
|
}
|