如何在没有公共客户端或BFF模式的情况下使用KeyCloak保护授权服务器?

huangapple go评论96阅读模式
英文:

How to secure an authorization server without a public client or BFF pattern with KeyCloak?

问题

I currently got an OAuth2 Resource Server configured - similar to Ch4mpy's set-up on GitHub. As for the OIDC Provider I'm using KeyCloak. Everything works so far - I can easily send my requests to the Authorization Server (KeyCloak) via e.g. Postman, get JWT and authenticate myself to access the resources I'm allowed according to the RBAC that I configured.

Now I'm heavily struggling with connecting my front-end applications with my back-end. In our system we got multiple apps (both B2B and B2C of nature - so different access points) and a variety of other front-end interfaces (like websites).

According to most documentations I now should either

  1. use public clients for all interfaces that aren't able to store client secrets.
  2. [or] use a BFF pattern for each front-end application.

Both aren't really feasible as the first suggestion would compromise security and the latter would require multiple servers to handle the communication.

Thus I've been thinking towards implementing a back-end that would get sufficient privileges (i.e. a confidential client) that sits in between all front-end applications and the authorization server. Unluckily, I wasn't able to find proper resources because with that matter comes new issues:

  • How to secure the back-end application? (I.e. Make sure that no unauthorized calls can access it)
  • How does the authentication flow work when a back-end server is in between these instances?
  • How to integrate further IDPs (like Google Sign-In or Apple Sign-In) in this architecture?

All in all, how to "secure" the authorization server when not using a public client or a 1-on-1 BFF client for all front-end applications?

英文:

I currently got an OAuth2 Resource Server configured - similar to Ch4mpy's set-up on GitHub. As for the OIDC Provider I'm using KeyCloak. Everything works so far - I can easily send my requests to the Authorization Server (KeyCloak) via e.g. Postman, get JWT and authenticate myself to access the resources I'm allowed according to the RBAC that I configured.

Now I'm heavily struggling with connecting my front-end applications with my back-end. In our system we got multiple apps (both B2B and B2C of nature - so different access points) and a variety of other front-end interfaces (like websites).

According to most documentations I now should either

  1. use public clients for all interfaces that aren't able to store client secrets.
  2. [or] use a BFF pattern for each front-end application.

Both aren't really feasible as the first suggestion would compromise security and the latter would require multiple servers to handle the communication.

Thus I've been thinking towards implementing a back-end that would get sufficient privileges (i.e. a confidential client) that sits in between all front-end applications and the authorization server. Unluckily, I wasn't able to find proper resources because with that matter comes new issues:

  • How to secure the back-end application? (I.e. Make sure that no unauthorized calls can access it)
  • How does the authentication flow work when a back-end server is in between these instances?
  • How to integrate further IDPs (like Google Sign-In or Apple Sign-In) in this architecture?

All in all, how to "secure" the authorization server when not using a public client or a 1-on-1 BFF client for all front-end applications?

答案1

得分: 2

在你的情况下,“授权服务器”是Keycloak。您没有为其提供Spring Security配置。要防止暴力攻击、记录登录尝试等,请参考Keycloak文档。同样适用于添加联合身份源(例如来自Google或Facebook的“社交”登录,以及企业LDAP等)。

一个“前端所有前端的后端”被称为BFF。BFF配置为机密客户端,并使用会话保护其来自前端的请求。如果您想要记录授权代码流程的启动,请参考底层中间件文档(例如如果将其用作BFF,则参考spring-cloud-gateway)。

但是我已经在你所参考的教程中解释过了…

英文:

In your case, the "authorization server" is Keycloak. You don't provide Spring Security configuration for it. To prevent brute force, log login attempts, etc, refer to Keycloak documentation. Same for adding federated identity sources (like "social" login from Google or Facebook, but also a corporate LDAP or whatever).

A "backend in front of all the front-ends" is a BFF. BFF is configured as a confidential client and secures it's requests from front-ends with sessions. If you want to log authorization_code flow initiations, there, refer to the underlying middleware documentation (like spring-cloud-gateway if using it as BFF)

But I already explained that in the tutorials you are referring to...

huangapple
  • 本文由 发表于 2023年6月26日 18:14:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76555711.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定