I am attempting to perform access control to a specific URI based on IP address. We would like to permit all internal traffic to anything on the host but would like to restrict a vendors public IP adress to only be able to access a single uri.
This works:
when HTTP_REQUEST {
if { [matchclass [IP::client_addr] equals internal-access-dg]}{
} elseif { [HTTP::uri] starts_with "/foo" and not ([IP::addr [IP::client_addr] equals 10.10.10.10/32])}{
reject
} else {
}
}
We are anticipating having quite a few of these cloud vendors that will need to connect to specific URIs as new applications are developed. I would like to simplify management down the road by creating a datagroup that contains the vendors IP(s) and their URI within the application to do a lookup of the URI then associate the paired IP address to permit access to the URI to only its matching IP address.
I have this built, i know its wrong but im stuck here
when HTTP_REQUEST {
if { [matchclass [IP::client_addr] equals internal-access-dg]}{
} elseif { [class match [string tolower [HTTP::uri]] starts_with external-access-dg] and not ([IP:addr [IP::client_addr] [class search -value external-access-dg starts_with [HTTP::uri]])}{
reject
} else {
}
}
The external-access-dg datagroup is set up like: /foo:=10.10.10.10/32
Any help would be appreciated.