简体   繁体   English

如何使用Django保护第三方API数据?

[英]How To Secure Third Party API data using Django?

I'm using a third party API Key for my website. 我正在为我的网站使用第三方API密钥。 I have done some modification on that API and now I'm using it for my own site. 我已经对该API进行了一些修改,现在将其用于自己的网站。

I want to secure that API data by adding a restriction on any user (Authenticated or Anonymous ). 我想通过对任何用户(已认证或匿名)添加限制来保护该API数据。

I want to add a time limit on the data provided by the API. 我想对API提供的数据添加时间限制。 So, if anybody uses the same data after a certain period of time then it will show an error. 因此,如果有人在一定时间后使用相同的数据,则将显示错误。

As well as I want some restrictions on users IP. 以及我想要对用户IP进行一些限制。 So, a user can access my website a fixed number of time. 因此,用户可以固定时间访问我的网站。

You might want to use the Django REST Framework JWT Authentication. 您可能要使用Django REST Framework JWT身份验证。

I implemented https://github.com/davesque/django-rest-framework-simplejwt 我实现了https://github.com/davesque/django-rest-framework-simplejwt

It works - the installation is rather easy - read the docs :) 它有效-安装非常简单-阅读文档:)

if you are using DRF use the authentication class settings. 如果您使用的是DRF,请使用身份验证类设置。 If you are using normal Django views you can wrap the view with a login_required decorator 如果您使用的是常规Django视图,则可以使用login_required装饰器包装视图

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

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