TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Keycloak, Angular, and the BFF Pattern

57 点作者 brakmic4 个月前

8 条评论

malwrar4 个月前
I don’t understand the benefit of adding this intermediate component vs just writing frontend code to interact with the APIs you’d otherwise already be calling. An HTTP server with sessions placed between clients and internal systems makes sense and is standard, but the weird callback-style “remote control” system seems completely unnecessary and inefficient to me. I don’t think client logic being married to some backend vs the client itself makes any real guarantees about functionality being maintained either, it just adds a new location where code needs to be changed when something upstream changes.
评论 #42859108 未加载
评论 #42856853 未加载
评论 #42857031 未加载
necovek4 个月前
Formally proving that you can&#x27;t be authenticated to a service without actually holding some type of authentication token is trivial.<p>Whatever you replace it with (a short-lived access token, a session cookie, a JWT, or whatever else) becomes <i>the</i> authentication token — if you add other properties (like short expiry), you are mostly trading convenience for security (eg. people will get logged out, or you&#x27;ll need to implement refresh token dance in your app).<p>So it&#x27;s really confusing to me how can someone pretend that there is something you can do on the unsafe client side, because you really can&#x27;t (sure, there are obvious things you shouldn&#x27;t do, like keep a plain text password in a cookie or localStorage, but an auth token is pretty much the same thing other than expiry).
评论 #42870351 未加载
steeeeeve4 个月前
The BFF pattern is just &quot;mostly microservices dedicated to a particular client type&quot;.<p>It makes sense when you have drastically different needs between a desktop client and a mobile client (or maybe for a kiosk client or POS interface)<p>Hosting a microservice is cheap, it avoids unnecessary workload on backend data stores, and teams can operate with more autonomy if they don&#x27;t have to cooperatively update APIs in coordination with other groups with differing priorities.<p>This article really just reads like &quot;I figured out how to do authentication with keycloak using OIDC&quot;
评论 #42857690 未加载
windlep4 个月前
I&#x27;ve looked over the code, and some things seem a little odd to me.<p>The article starts by mentioning how insecure the browser is, apparently even cookies aren&#x27;t secure. But then the API to talk to the BFF uses.... a server-side session tracked via a client cookie. If the BFF is holding the oauth credentials, then someone could steal the client cookie to make requests to the BFF to do whatever it can do.<p>It&#x27;s not impossible to secure the browser from having credentials stolen from inside it, but it can be tricky to ensure that when the browser sends the credential in the request it doesn&#x27;t leak somehow.<p>There&#x27;s some irony as OAuth has DPoP now which can reduce the usefulness of stolen in-flight credentials but that can&#x27;t be used in this BFF setup because the browser client needs the private key to sign the requests.<p>Properly securing the browser content on a login page, or the subdomain handling authentication credentials is definitely a challenge, and many don&#x27;t like having to eliminate&#x2F;audit any 3rd party JS they include on the page. I can see the appeal of a solution like this, but the trade-off isn&#x27;t great.
yearesadpeople4 个月前
BFF pattern is very much misunderstood, and very much over-used IMHO<p>Perhaps most useful - in highly distributed systems - I&#x27;ve seen is when we require some kind of flow orchestration, where we wouldn&#x27;t like the orchestration logic at the API implementation (or indeed require the downstream services to not have to consider different contexts).<p>[edit] Quite useful when designing nice clean, dedicated, new APIs and having to deal with legacy systems (perhaps data pertaining to the shiney new API model is housed in a legacy model): a useful means to keep moving forward.
sqoopd4 个月前
I’m linking this draft discussing BFF from oauth perspective.<p><a href="https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;html&#x2F;draft-ietf-oauth-browser-based-apps#name-backend-for-frontend-bff" rel="nofollow">https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;html&#x2F;draft-ietf-oauth-brows...</a>
cjcampbell4 个月前
I’m surprised that the author chose to configure a public OIDC client for this scenario. Part of the benefit of this pattern is that it’s possible to use a confidential client, since the BFF can securely hold the client secret.
lakomen4 个月前
And I thought it&#x27;s best friends forever! SCNR