简体   繁体   English

只允许一个应用访问 api 端点?

[英]Only let one app have access to api endpoint?

I am gonna have an open source app in which it needs to send some data to an fastapi python api, how can i make it so that only the app can make requests to the api and not some random person abusing the api endpoint? I am gonna have an open source app in which it needs to send some data to an fastapi python api, how can i make it so that only the app can make requests to the api and not some random person abusing the api endpoint?

There are so many ways to do that.有很多方法可以做到这一点。 Even some of the techniques doesn't bother the API endpoint.甚至某些技术也不会打扰 API 端点。

  1. IP Restriction: You can restrict an IP from cloud provider which IP can call the API. IP 限制:您可以限制来自云提供商的 IP,IP 可以调用 ZDB974238714CA8DE6347A。 Even you can have multiple IPs.即使您可以拥有多个 IP。
  2. API KEY: You can provide an API KEY to the API client. API KEY:您可以向 API 客户端提供 API KEY。 When the request come along with the provided key then you work on it otherwise ignore.当请求与提供的密钥一起出现时,您可以处理它,否则忽略。

The IP method is much better than doing on the application end. IP 方法比在应用端做的要好得多。

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

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