简体   繁体   English

Facebook身份验证:服务器端与客户端。 的Python / Django的

[英]Facebook authentication: server-side versus client-side. Python/Django

I have a website that essentially requires that the user be logged in to see anything. 我有一个网站,基本上要求用户登录后才能看到任何内容。 If they are not logged in then they are redirected to the front page and a login form. 如果未登录,则将它们重定向到首页和登录表单。

I currently use Django's standard authentication and test for authentication server-side before returning the page. 我目前使用Django的标准身份验证,并在返回页面之前对服务器端进行身份验证。

I now want to add Facebook login and authentication. 我现在想添加Facebook登录名和身份验证。 Does this mean that I need to make a server-side call to Facebook and verify authentication every single time that a user navigates to any page? 这是否意味着我需要在用户每次访问任何页面时向Facebook进行服务器端调用并验证身份验证? It seems that this will add quite a number of calls and potential page delays. 看来这将增加大量的呼叫和潜在的页面延迟。

Or, is this not really a concern (Facebook call is fast) or is there some other clever way that I am missing? 或者,这真的不是一个问题(Facebook通话很快),还是我缺少其他聪明的方法? Somehow move the call client-side where I believe that Facebook uses caching? 以某种方式将呼叫客户端移动到我认为Facebook使用缓存的位置?

I've looked at some of the Django/Facebook packages, but none seem to explain the overall strategy, which is what I'm looking to understand. 我看过一些Django / Facebook软件包,但似乎没有一个能解释整体策略,这就是我想要了解的内容。 The tutorials that I have looked at describe how to login, but don't worry about what happens once a user logs out of Facebook. 我看过的教程描述了如何登录,但是不用担心用户注销Facebook后会发生什么。

Basically, the user logs in once using facebook (this will make a request to facebook). 基本上,用户使用Facebook登录一次(这将向Facebook发送请求)。

once is logged in, it will behave just as a normal django user (most apps create a Django User for each facebook user) 一旦登录,它将像普通的django用户一样运行(大多数应用为每个facebook用户创建一个Django用户)

Only when the access token is expired (the "password" for using the facebook data) than you will need to make a connection to facebook again. 仅当访问令牌过期(使用Facebook数据的“密码”)时,您才需要再次建立与Facebook的连接。

Ill recommend you to use Python Social Auth which basically does everything for you. 建议您使用Python Social Auth ,它基本上可以为您完成所有工作。

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

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