简体   繁体   English

如何使用Backbone.js / Javascript前端实现Oauth / OpenID / Custom身份验证?

[英]How to implement Oauth/OpenID/Custom authentication with Backbone.js/Javascript frontend?

I have a site and our backend and frontend ( 100% backbone) are decoupled RestFul (JSON + Ajax), and we are thinking about how to implement the user authentication now. 我有一个站点,我们的后端和前端(100%主干)是解耦RestFul(JSON + Ajax),我们正在考虑如何实现用户身份验证。

We want to support facebook, Google and others (OAuth and OpenId) and also our custom method to users who don't have or don't want to use their other accounts. 我们希望支持facebook,Google和其他人(OAuth和OpenId)以及我们的自定义方法给那些没有或不想使用其他帐户的用户。

How do you do your custom authentication? 你如何进行自定义身份验证? What are the best pratices for that ? 有什么最好的实践?

Do you use OAuth or OpenID for your custom login too ? 您是否也使用OAuth或OpenID进行自定义登录?

Oauth has worked for me in the past when using my own custom authentication. 在使用我自己的自定义身份验证时,Oauth过去曾为我工作过。 There is a very good library available to handle most of the work. 有一个非常好的图书馆可以处理大部分工作。

http://oauth.googlecode.com/svn/code/javascript/ http://oauth.googlecode.com/svn/code/javascript/

If you are using node.js as the restFul server you can use Passport Middleware http://passportjs.org/ to handle most of the server side. 如果您使用node.js作为restFul服务器,则可以使用Passport Middleware http://passportjs.org/来处理大多数服务器端。

The documentation for Passport also includes some good generic examples and strategies that could be implemented on any stack. Passport的文档还包括一些可以在任何堆栈上实现的通用示例和策略。 https://github.com/jaredhanson/passport#strategies-1 https://github.com/jaredhanson/passport#strategies-1

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

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