从localhost:3000上的Keycloak接收403禁止访问?

问题描述:

我正在构建一个基于ReactJS的Web应用程序,它在http://localhost:3000的构建过程中正在运行.出于安全原因,所有后端和Web应用程序均通过Keycloak进行保护. 目前,Keycloak和后端服务帐户正在Kubernetes集群上运行,如下图所示:

I am building a web app based on ReactJS and it is running during the bulding process on the http://localhost:3000. For security reason, all backend and web apps are protected through Keycloak. At the moment, Keycloak and backend service account are running on the Kubernetes cluster as you can see on the picture below:

该Web应用程序也是通过Keycloak购买的,并且在http://localhost:3000上运行.因此,当我启动Web应用程序时,它会将我重定向到Keycloak的登录页面.成功登录后,它将重定向回Web应用程序.然后,Web应用程序向后端服务https://account.dev.example.io发出请求,我收到返回的http代码 403 .

The web app is also procected through Keycloak and it is running on http://localhost:3000. So, when I start the web app, it redirects me to the login page of the Keycloak. After the successfull login, it redirects back to the web app. Afterwards, the web app makes a request to the backend service https://account.dev.example.io and I receive the return http code 403.

是否由于http协议而不是https收到返回代码403?
还是我做错了什么?

Do I receive the return code 403 because of http protocol instead of https?
Or what am I doing wrong?

更新

以下是请求和响应的概述:

Here is the overview of the request and response:

我忘了提到我在kubernetes上运行了另一个Web应用程序,并且它还请求后端服务帐户.就像魅力一样.

I forgot to mention that I have one more web app running on the kubernetes and it also makes a request to backend service account. This works like a charm.

HTTP 403表示禁止访问/禁止访问".可能是您的React客户没有利用从密钥斗篷获得的access_token.

HTTP 403 means Forbidden / No access. It could be that your react client is not utilizing the access_token it gets from keycloak.

您应该检查Google的AppAuth-JS项目,它不仅可以在浏览器中而且可以在本机应用程序中帮助进行身份验证流程

You should check out Google's AppAuth-JS project, it can help with the auth flow not only in browsers but native applications

https://github.com/openid/AppAuth-JS