mirror of
https://github.com/zitadel/zitadel.git
synced 2026-11-02 20:30:51 -06:00
This PR adds a possibility to deny certain domains and/or IPs as targets for action v2.
By default, localhost as well as loopback IPs are denied.
(cherry picked from commit b2532e9666)
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
|
|
}
|