0

I added the external api through zuul routes successfully in jhipster gateway. However when I test in postman, it is not asking for any authentication. I need to secure this external api with the authentication provided by jhipster. Please advise

Below is the code I use to add zuul routes.

    ZuulProperties.ZuulRoute zuulRoute = new ZuulProperties.ZuulRoute();
    String path = externalapis.getPath();
    zuulRoute.setId(externalapis.getServiceId());
    zuulRoute.setStripPrefix(true);
    zuulRoute.setServiceId(externalapis.getServiceId());
    zuulRoute.setPath("/"+externalapis.getServiceId()+"/**");
    zuulRoute.setLocation(externalapis.getUrl());
    zuulRoute.setUrl(externalapis.getUrl());
    zuulRoute.setRetryable(true);
    this.zuulProperties.getRoutes().put(externalapis.getServiceId(), zuulRoute);
    this.discoveryClientRouteLocator.refresh();
Developer404
  • 5,716
  • 16
  • 64
  • 102
  • Which url? Did you add this new route to gateway property `jhipster.gateway.authorized-microservices-endpoints`? See https://www.jhipster.tech/common-application-properties/#2 – Gaël Marziou Jul 02 '19 at 17:12
  • Tried. It still doesn't ask for JWT authorization – Developer404 Jul 04 '19 at 06:39
  • When do you create your route? Maybe it's too late or too early. Did you set a breakpoint in debugger in AccessControlFilter#shouldFilter() to inspect routeLocator? Or maybe there is something specific to the path of your route? – Gaël Marziou Jul 04 '19 at 06:48
  • Ok. Let me try to debug. I create routes dynamically using the code pasted in my question. I get error while I try to debug in which am working on. [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.7.RELEASE:run (default-cli) on project gateway: Could not exec java: Cannot run program "C:\Program Files\Java\jdk1.8.0_202\jre\bin\java.exe": CreateProcess error=206, The filename or extension is too long -> [Help 1] – Developer404 Jul 05 '19 at 03:08
  • Personally I debug by running the application's main class from the IDE rather than through maven plugin – Gaël Marziou Jul 05 '19 at 09:24

0 Answers0