spring-cloud-gateway | Spring Cloud Gateway with Keycloak for Access | Microservice library
kandi X-RAY | spring-cloud-gateway Summary
kandi X-RAY | spring-cloud-gateway Summary
Spring Cloud Gateway with Keycloak for Access and Identity Management and Resilience4j for fault tolerance and resiliency, Prometheus and grafana for monitoring, jaeger for distributed tracing on kubernetes
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- The reactive resilience factory bean
- Spring security filter chain
- Registers the global authentication provider with the authentication manager
- The key resolver for the remote address
- Customizer for custom metrics
- Default ms2 web client
- Configures authorization requests
- Gets home token
- Get the session index
- The main entry point
- Main entry point
- Create M3 web client
- Custom metrics common tags
- Main application
spring-cloud-gateway Key Features
spring-cloud-gateway Examples and Code Snippets
Community Discussions
Trending Discussions on spring-cloud-gateway
QUESTION
I'm trying to use spring cloud gateway with spring security and trying to call the rest API through angular but I'm getting following error
...ANSWER
Answered 2021-Apr-26 at 16:08I solved it by moving Angular App behind the API gateway and added the following code in the API Gateway and Microservice
In API Gateway
QUESTION
I provide an api for other microservices in my spring boot microservice and I want to put a spring-cloud-gateway in front of this microservice.
I have reviewed the well-known spring document (https://spring.io/guides/gs/gateway/) but as far as I understand it requires me to launch the cloud gateway in a separate project. But I want to run the RouteLocator bean there in my microservice. Not in a separate project, but in the same project.
When I use it in the same project, I get a warning like this
"Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. Please remove spring-boot-starter-web dependency."
Later, as he said in the warning, I remove the spring-boot-starter-web dependency, even coming in other projects, excluding them from there like this
...ANSWER
Answered 2021-Mar-22 at 08:17You can start gateway in the same project, but this is a webflux based project. From documentation
Spring Cloud Gateway is built on Spring Boot 2.x, Spring WebFlux, and Project Reactor. As a consequence, many of the familiar synchronous libraries (Spring Data and Spring Security, for example) and patterns you know may not apply when you use Spring Cloud Gateway. If you are unfamiliar with these projects, we suggest you begin by reading their documentation to familiarize yourself with some of the new concepts before working with Spring Cloud Gateway.
and
Spring Cloud Gateway requires the Netty runtime provided by Spring Boot and Spring Webflux. It does not work in a traditional Servlet Container or when built as a WAR.
so you should have used spring-boot-starter-webflux
instead of spring-boot-starter-web
.
Alternatively, if you need to use traditional Spring MVC, consider using Spring Netflix Zuul. This project is currently in maintenance mode and Spring Gateway is the successor of it, but it should work.
QUESTION
I am using the following dependencies in one application: Spring-Cloud-Gateway, Spring Boot OAuth2 Client, Spring Boot OAuth2 Resource Server.
I use the following security config:
...ANSWER
Answered 2021-Feb-24 at 21:12Turns out that I misunderstood some basic OAuth2 concepts. The Authorization itself is working correctly when I send a JWT in the Authorization header (Implicit Flow). What did not work is the case when I tried to access a resource via the browser. I got redirected to the login page of Keycloak (Authorization Code Flow). After you sign in through the login page of Keycloak you do not receive the JWT but a Keycloak Session ID. Spring Cloud Gateway cannot perform Authorization on the basis of a Keycloak Session ID (do not know how that would work if I wanted to use Authorization Code Flow but I am using Implicit flow, so I am fine for now).
QUESTION
I am trying to implement a Custom Filter for the Authorization Header in my Spring Cloud API Gateway by following this resource spring-cloud-gateway-creating-custom-route-filters-abstractgatewayfilterfactory.
Here's my setup.
pom.xml
...ANSWER
Answered 2021-Feb-23 at 05:33I think the problem is because you have 2 constructors, 1 is empty, 1 is autowired. Try to remove the empty constructor and move the super method inside the 2nd constructor like this.
QUESTION
I am developing a microservice infrastrucutre, and began by implementing a Spring Cloud Gateway to proxy all my requests. I secured my Gateway with keycloak via the spring-boot-starter-oauth2-client Dependency. I use the TokenRelay Filter to append the Bearer to my proxied requests. I basically followed this Blog https://blog.jdriven.com/2019/11/spring-cloud-gateway-with-openid-connect-and-token-relay/
...ANSWER
Answered 2021-Feb-01 at 08:27So for anyone having a similar problem. The problem was in the spring-boot-starter-oauth2-client dependency. This made my gateway stateful, by sending back a SESSION-Cookie instead of an Access-Token from the authorization server.
Unfortunately i couldn't use the official Spring-Boot-Adapter, provided by Keycloak (https://www.keycloak.org/docs/latest/securing_apps/#_spring_boot_adapter) because this Adapter has some web dependencies, and as the spring-cloud-gateway is built on webflux, the web dependencies required by keycloak cannot be used in conjunction.
My solution is, to not use the spring-cloud-gateway anymore, but the spring-cloud-starter-netflix-zuul gateway. This is built on web, and not on webflux, so i was able to use the official Spring-Boot-Adapter by keycloak with it.
QUESTION
I'm reading the article on how to secure my Spring Cloud Gateway with the token relay pattern.
https://spring.io/blog/2019/08/16/securing-services-with-spring-cloud-gateway
See https://static.spring.io/blog/bwilcock/20190801/demo.png
After a user requests a resource, the gateway redirects him to the login page of the identity provider to authenticate himself. On success, the identity provider redirects you back to the original requested resource (the gateway), including the access-token provided by the identity provider.
So now the gateway is secured. Why does the resource-server has to validate the access-token again against the identity provider? Didn't the gateway just validate it? Or didn't it, and the gateway is just there to relay the access-token to the resource-server so he can validate it?
...ANSWER
Answered 2021-Jan-27 at 08:20Basically never trust the JWT.
Finally, the Resource Server needs to know where it can find the public keys to validate the authenticity of the access token which it has been given. The UAA provides an endpoint which both the Resource Server and the Gateway rely upon at runtime to do this check. The endpoint is configured in the application.yml for each application
The resource server can never be 100% sure that the access-token was created by the Identity-Provider, or even came from the gateway. So at least, you should make sure that the access-token was signed by the Identity-Provider by using the public key, exposed by a configured endpoint.
QUESTION
So I've got a multi-container application with a front-end, back-end API all sat behind an API gateway. At the moment all apps work fine when booted independently through their respective commands (Java spring apps and an Angular front-end). However, when I start the apps through docker-compose up
, none of the apps can communicate with each other (getting a connection refused).
The Gateway is just a basic spring-cloud-gateway starter app which routes requests through to the correct application. This is configured with the following code:
...ANSWER
Answered 2021-Jan-11 at 00:27Thanks to @DavidMaze for making me notice this.
Seems like I was being a bit of a fool. My apps are sending network requests to localhost. This works fine when they are all running outside of a container. When in a container they need to be sending requests to the names of the other containers. For example:
app_1 runs on port 8080 app_2 runs on port 5000
When running outside of docker, app_1 could send a network request to app_2 via http://localhost:5000
. This does not work inside of a container as nothing is running on localhost:5000
in that container. Instead, it will need to reference the other container eg: http://app_2:5000
.
QUESTION
I have the following Spring-Cloud-Gateway
configuration and controller endpoint targeted by that configuration but my @RequestBody
parameter is always null when the request reaches the endpoint. Could you please direct me as to how I should modify my Spring-Cloud-Gateway
configuration, so that problem does not persist?
ANSWER
Answered 2020-Nov-03 at 08:36The problem had nothing to do with the spring-cloud-gateway configuration. On Insomnia
I had to specify
QUESTION
I am using Spring Cloud Gateway as an API-Gateway and also as a webserver hosting the static files (html/js/css) of an Vue.js SPA.
Preclaimer: I'm not able to change this (bad) architecture due to organisational constraints.
Currently, I'm using the default Vue Router hash mode, meaning client-side routing of the Vue app is accomplished via an URL hash like
...ANSWER
Answered 2020-Aug-07 at 11:08You could fix it from the Spring Boot side. I mean, you could:
- Enable the Vue Router history mode like explained in the documentation here
- Build a Spring Boot forwarding controller like this:
QUESTION
We have written a custom Predicate factory for the Spring-Gateway to route the requests. We are parsing the body of an XML request and then the route is being derived, based on particular Method existing in the Body. While doing this we have written the following code to create the ServerRquest.
...ANSWER
Answered 2020-Jul-29 at 10:34The problem was, the greenwich version of those apis was beta. Now the object expected in CACHED_REQUEST_BODY_ATTR
is required to be a PooledDataBuffer
. So I changed my code accordinly now. Which looks like as following now:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-cloud-gateway
You can use spring-cloud-gateway like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the spring-cloud-gateway component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page