I need help in adding swagger ui for my spring cloud gateway microservice.
My spring cloud gateway service is routing the request to another microservice which already has swagger ui enabled since it has a controller layer
But since my spring cloud gateway service doesn't have any #Controller class and all the routes are defined in a RouteConfig class which doesn't do much except routing the request to actual service
Related
Have created an API Gateway microservice (Sprint Boot project), using the Spring Cloud Starter Gateway.
Also the API Gateway would do the SSO Authentication, and on successful authentication, the IDP would redirect the SAML assertion to the API gateway HTTPS endpoint.
Added the spring-cloud-starter-gateway dependency and excluded all the transitive dependencies.
i have added the spring-boot-starter-web dependency so that the IDP would be able to redirect to the API gateway HTTPS endpoint.
I tested the SSO Authentication and it worked fine, but then when i wanted to test the gateway routing, it was not working.
So had to comment out the excluded spring-cloud-gateway-server dependency for routing.
But it gave error that Spring Web MVC found on Classpath is incompatible with Spring Cloud Gateway.
Either make application reactive or remove web dependency.
So made the application reactive by adding property in application.properties file to make it reactive.
But now, while doing SSO authentication, i get the following error in the Browser,
type=Unsupported Media Type, status=415
Is there a way in which we could do WEB SSO Authentication in the API Gateway ??
TLDR : Is it okay to use controller class in spring gateway instead of routing in config class? I want to take data from one service and then pass it the response from that service to another.
I used spring cloud gateway to create an api gateway. I have several services that need to communicate. I currently only use the gateway for routing to the first service and then the first service is going to talk to other service by itself. But this is becoming troublesome now that I have a lot of services.
I have multiple Spring boot micro-services deployed to kubernetes. Im also using Spring Gateway & Eureka Discovery.
Those micro-services are secured with Spring Security and require JWT token for access to the endpoints. Im using #PreAuthorize methods etc.
It all works fine when I'm accessing those endpoints from frontend application that is sending JWT token in request,
but, I can't bypass that security in service-to-service communication via FeignClient.
Ideally, my micro-services wouldn't need token at all to call other micro-service's methods via FeignClient. But I still need that security when endpoints are accessed from frontend or when requests are coming from Spring Api Gateway.
Do you know some elegant solution to this problem?
I was thinking about adding another pair of endpoints that don't have security annotations (#PreAuthorize) and somehow disable access to those endpoints on Spring Api Gateway, so they cannot be accessed from outside, but only directlly by one of the micro-services.
I have faced with a problem of creating overview page in gateway service with links to documentations of all other microservices using Spring Rest Docs. I have microservice architecture, so gateway service and other service are different projects.
Gateway service just have only RouteLocator and CORS configurations. From Spring Rest Docs I have understand that I can attach only to spring application context only if I'm using #component or #service.
How to make an overview page with links on all documented microservices in gateway service?
I am just starting with Spring Integration with Spring Boot 2.
I am working on a application which uses Spring Integration's HTTP outbound gateway to consume a Spring boot Service.
I am consuming the spring boot service from Spring Integration application using Gateway.
When I call the Gateway method which in turn will use the outbound gateway to call the spring boot service, the request does not seem to be completed. It is just going on when I make the HTTP GET request via the browser.
The request is also not received by the Spring Boot service.
I am not able to identify what is wrong in my Integration application when using gateway to consume a Spring Boot 2 service.
I have shared my Spring Boot 2 Application and also the Integration application which I am using to consume it in the below github folder. it contains 2 folders, one for the spring Integration application and the other for the spring boot application.
https://github.com/gsamartian/spring-int-demos
I have exposed a REST interface for the Integration application using RestController.
I access the boot application from integration application via the url, http://localhost:8763/callExternalServiceViaGateway
I am able to access the spring boot application directly from its port.
If anyone can help me identify the cause it would be great.
Thanks,
Your problem that the gateway method is without any args:
#Gateway(requestChannel = "get.request.channel", replyChannel = "reply.channel")
String getCustomMessage();
In this case the gateway works as receiving. No any requests is send because nothing to wrap to the payload. See more info on the matter in the Reference Manual.
Right now I see several bugs with the payloadExpression and no arg, so I suggest you to add some String payload arg to the getCustomMessage() gateway method and perform it with an empty string.
Will take a look into the bugs and will fix them soon.
Thank you for a good sample how to catch and reproduce!
https://jira.spring.io/browse/INT-4448
https://jira.spring.io/browse/INT-4449