Django的内部API客户/服务器验证或不? [英] Django internal API Client/Server Authentication or not?

查看:114
本文介绍了Django的内部API客户/服务器验证或不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Django项目,其中我揭露了一些API端点(API端点=答案GET / POST,返回JSON响应,纠正我,如果我错了,我的定义)。这些端点使用我的前端,如更新计数或得到更新的内容,或无数其他的东西。我处理重新presentation逻辑上的服务器侧,在模板,并且在一些情况下,发送一个呈现给串模板到客户端。

I have a django project, in which i expose a few api endpoints (api endpoint = answers to get/post, returns json response, correct me if im wrong in my definition). Those endpoints are used by me on front end, like update counts or get updated content, or a myriad other things. I handle the representation logic on server side, in templates, and in some cases send a rendered to string template to the client.

所以这里的问题,我试着回答:

So here are the questions im trying to answer:


  1. 请我需要有客户端和服务器之间的某种认证?

  2. 是Django的跨原产地保护还不够吗?

  3. 其中,在这张照片,适合这样的包,比如 Django的OAuth的工具?和 Django的休息框架

  4. 如果我不加客户端和服务器之间的任何身份验证,我要离开我的服务器开放的攻击?

此外,所讲述的服务器到服务器的连接?我的控制下,这两个服务器。

Furthermore, what goes for server-to-server connection? Both servers under my control.

推荐答案

我会强烈建议您使用 Django的tastypie 获取服务器到客户端通信。
我曾在许多应用中使用它既服务器到服务器或服务器到客户端。
这使您可以使用Django的安全性,以及一些关于授权过程更多的逻辑。
它也提供了现成的:

I would strongly recommend using django-tastypie for server to client communication. I have used it in numerous applications both server to server or server to client. This allows you to apply the django security as well as some more logic regarding the authorization process. It offers also out of the box:


  • 节流

  • 序列化JSON,XML等格式

  • 验证(基本,apikey,定制等)

  • 验证

  • 授权

  • 分页

  • 缓存

因此​​,作为一个整体的概述,我建议对建立在这样一个框架,让您的内部API,用于将来的扩展,更安全更好的互操作性。

So, as an overall overview i would suggest on building on such a framework that would make your internal api more interoperable for future extensions and more secure.

要明确现在回答你的问题,我绝不会没有至少一些基本的认证/授权启用任何服务器API。

To specifically now answer your question, i would never enable any server api without at least some basic authentication/authorization.

希望我回答你如何你可以用一个框架,提供所有上述担忧的问题。

Hopefully i answer your questions on how you can deliver all of your above worries with a framework.

Django的,其余的框架,你要求的,也确实先进,使用方便,但我preFER tastypie为我解释原因。

The django-rest-framework that you ask for, is also really advanced and easy to use, but i prefer tastypie for the reasons i explain.

我希望我帮一点!

这篇关于Django的内部API客户/服务器验证或不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆