简体   繁体   English

如何将 Next-auth 凭证提供程序与永恒的 API 一起使用

[英]How to use Next-auth credentials provider with eternal API

I worked with Next-auth before but I also used the built in next API feature.我之前使用过 Next-auth,但我也使用了内置的下一个 API 功能。 When used with next API, I can protect my APIs.与下一个 API 一起使用时,我可以保护我的 API。 The problem is now I am using an external node.js API.问题是现在我使用的是外部 node.js API。 The token is created in the front end and this leaves my node API endpoints exposed.令牌是在前端创建的,这使我的节点 API 端点暴露。 Is there something I'm missing here?我在这里缺少什么吗? How should I do this?我该怎么做? Or tell me if there is a better way.或者告诉我是否有更好的方法。 Thanks a lot!非常感谢!

You should not generate any JWT tokens in the frontend as that is way to insecure.您不应在前端生成任何JWT令牌,因为这是不安全的方式。 Better to work if a dedicated and separate authorization service that generates the token for you.如果为您生成令牌的专用且单独的授权服务更好地工作。 Either you host one your self or use a third party solution like Auth0 to generate the tokens for you.您可以自己托管一个,也可以使用Auth0等第三方解决方案为您生成令牌。

Today more and more moves towards using the BFF pattern to further secure their SPA applications.今天,越来越多的人转向使用BFF 模式来进一步保护他们的 SPA 应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM