Require basic auth only if source IP is not in ipwhitelist


I would like to use the ipwhitelist and basicauth middlewares in tandem. The behavior I am after is that if a client is not coming from a specific IP address, present the HTTP Basic Auth prompt, else let him in.

I have tried doing this with two routers, but quickly realised that that won't work, as the two conditions are racing based on priority.

Is it possible to implement this somehow, or is it not?

Thank you!