'Is it possible to require authentication on certain path, but not when certain request param is provided?

Controller:

@GetMapping(path = "/new")
public String method(@RequestParam(required = false) final String hash) {
        ...
}

Get request on /new without provided hash should be authenticated, but if hash is provided, it does not have to be. Is there something like this achievable in spring boot security?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source