简体   繁体   English

Django身份验证

[英]Django Authenticate

Having for instance http://mywebsite.com?increase_counter=true/ 例如具有http://mywebsite.com?increase_counter=true/

I want to let someone increase counter on my database with a GET request but only when he is authenticated. 我想让某人通过GET请求增加我的数据库中的计数器,但仅当他通过身份验证时。 How can someone be authenticated when coding in something external? 在外部进行编码时如何认证某人? eg shell or API. 例如shell或API。

Should I consider using tokens in GET request or is there an easy way to firstly authenticate someone with a simple request POST or GET and then execute url? 我应该考虑在GET请求中使用令牌,还是有一种简单的方法首先通过简单的POST或GET请求对某人进行身份验证,然后执行url? EG I want to authenticate myself to django app with a simple shell. EG我想用一个简单的外壳对django应用程序进行身份验证。 How to do it? 怎么做? Maybe another way? 也许是另一种方式?

I think your easiest approach is to include some sort of authentication tokens with the GET itself. 我认为您最简单的方法是在GET本身中包含某种身份验证令牌。 The problem is that in order for you to be able to use other forms of authentication, you'll need to actually package the data (HTTP Authentication requires an authentication header, traditional authentication requires a cookie header). 问题是,为了使您能够使用其他形式的身份验证,您需要实际打包数据(HTTP身份验证需要身份验证标头,传统身份验证需要Cookie标头)。

If all you want to do is create a simple point-of-entry, then GET parameters are no more complicated than concatenating some strings. 如果您要做的只是创建一个简单的输入点,那么GET参数并不比串联一些字符串更复杂。

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

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