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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: How do I secure my REST API?

1 点作者 lamina将近 10 年前
I&#x27;ve recently built a REST consuming web-app with a user account system. While I&#x27;m choosing not to store sensitive data such as passwords (using Google&#x2F;Facebook), I&#x27;d prefer to prevent just anybody from accessing the REST endpoints. What are some good ways of doing this? The app is using the MEAN stack.<p>Also, security is REALLY not my forte, and this side-project isn&#x27;t monumental or anything, so I&#x27;m willing to sacrifice some security for brevity and ease-of-use.

2 条评论

arisAlexis将近 10 年前
Usually you put a filter mechanism so some endpoints are restricted. This checks for a valid token sent by the client (by sending it back to facebook). If you find this procedure slow you can also use good old sessions (although some people consider this stateful and thus not appropriate (I am not in this camp).
phantom_oracle将近 10 年前
If your API is meant for other developers to build-upon, you use public-keys and registration, just like how you registered to use Google&#x2F;Facebook login.<p>You should also sanity-check your GET&#x2F;POST requests, to make sure they contain ONLY what is allowed.<p>There are many other things you can do, but I can&#x27;t think of them right now.