Nike-Inc / riposte

Riposte is a Netty-based microservice framework for rapid development of production-ready HTTP APIs.
Apache License 2.0
124 stars 34 forks source link

RequestSecurityValidator should have the ability to return a full response #79

Open nicmunroe opened 6 years ago

nicmunroe commented 6 years ago

RequestSecurityValidator.validateSecureRequestForEndpoint(...) currently has a void return type, with the idea that if the request passes auth you do nothing, and if it fails auth you throw an appropriate exception.

We should change the return type to Optional<ResponseInfo<?>> to allow you to short circuit with an explicit full-flexibility response if you wanted to. For example, you might want to send a 302/307 redirect.

So there would be three options for handling a request in RequestSecurityValidator.validateSecureRequestForEndpoint(...):

This would be an API breaking change.

rabeyta commented 6 years ago

To toss out another API breaking change, maybe considering changing the API to return a CompletableFuture instead of assuming a quick, fast response on the main thread when you make this change.

CompletableFuture<Optional<ResponseInfo<?>>> validateSecureRequestForEndpoint

This would remove the need for isFastEnoughToRunOnNettyWorkerThread flag