spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.53k stars 3.32k forks source link

When routes.predicates.RemoteAddr be set, and request was forbidden, the result is not clear enough. #2194

Open tain198127 opened 3 years ago

tain198127 commented 3 years ago

Is your feature request related to a problem? Please describe.

When I set RemoteAddr config in routes.predicates, if request was forbidden by ip, the result was not clear enough ,just show 404, but I want more clear infomation,like 403 or other some info.

Describe the solution you'd like I hope when request was forbidden by RemoteAddr, give a callback or some clear exception, so we can handle it.

Describe alternatives you've considered I knew io.netty.handler.ipfilter.IpFilterRuleType have another value REJECT , but I didn't find it in Spring Cloud Gateway, maybe could consider it in Spring Cloud Gateway.

spencergibb commented 3 years ago

403 forbidden is more along the lines of something spring security would handle. Route Predicates only have a true/false value currently. This would require a major modification to gateway. Marking as waiting for votes to see if anyone else would want this. If so, we'd have to weigh the cost in making a major version change for this.

xavier-b commented 2 years ago

Predicates are used to find the route to use. I think we should not change this and keep the Remote Addr Predicate as it is. For this problem, maybe you need a new Gateway Filter in addition (for example RemoteAddrFilter).