When we add the Micronaut security all the URLs are protected. while using the @Secured(SecurityRule.IS_ANONYMOUS)
annotation still facing the 401 exception
public interface ISubCategoryOperation {
@Get("/{categoryId}/sub-category")
@Secured(SecurityRule.IS_ANONYMOUS)
Maybe<?> get(@NotNull String categoryId);
}
The interface method is denoted with @Secured(SecurityRule.IS_ANONYMOUS)
but still not able to go to the controller method
Http client
@Client(id="feteBirdProduct", path = "/category")
public interface ISubCategoryClient extends ISubCategoryOperation{
}
Controller
@Controller("/category/{categoryId}/sub-category")
public class SubCategoryController implements ISubCategoryOperation {
@Override
public Maybe<?> get(@PathVariable String categoryId) {
return Maybe.Just(null);
}
Curl
curl -X GET "http://localhost:8080/api/v1/category/60236833af7a1d49478d2bef/sub-category" -H "accept: application/json"
Http client logs
15:17:18.504 [default-nioEventLoopGroup-1-6] DEBUG i.m.h.client.netty.DefaultHttpClient - Sending HTTP GET to http://localhost:8081/category/60236833af7a1d49478d2bef/sub-category
15:17:18.535 [default-nioEventLoopGroup-1-6] DEBUG i.m.h.client.netty.DefaultHttpClient - Received response 401 from http://localhost:8081/category/60236833af7a1d49478d2bef/sub-category