使用angularjs和flask进行用户身份验证的正确方法 [英] Proper way for user authentication with angularjs and flask
问题描述
我目前正在使用Flask进行Web开发.我想构建一个web应用程序,将flask作为后端,并在前端使用angular.js. Json部分很简单,我的第一步工作顺利.但是现在我陷入了用户身份验证的困境.我读了很多书,但发现WTFForms在angular(没有CSFR Token)上不能很好地工作,所以我不能使用flask-security之类的东西.
I'm currently working my way through Web development with flask. I want to build a webapp with flask as backend and angular.js at the frontend. The Json part is straight forward, and my first steps work out well. But now I got stuck with User Authentication. I read a lot but found out, that WTFForms works not as well with angular (without the CSFR Token), so i can not use something like flask-security.
使用Angular und Flask进行用户身份验证的正确方法是什么,或者是最佳实践? (也许有人知道一个很好的示例应用程序,我可以通过示例来学习)
What is a proper way or maybe the best pratice for implementing User authentication with Angular und Flask? (Maybe someone knows a good example app I can learn from by example)
推荐答案
我已经编写了一些有关Flask的RESTful API的教程,所有的示例都可以使用:
I have written several tutorials on RESTful APIs with Flask, all with examples that are ready to use:
http://blog.miguelgrinberg.com/category/REST
这些教程是:
这是用Flask编写的带有身份验证的简单RESTful API.
This is a simple RESTful API written in Flask, with authentication.
在本文中,我为第一个教程中构建的API实现了Javascript客户端.在这里,您可以查看客户端如何进行身份验证.我为客户端使用Knockout而不是Angular,但是原理是相同的.
In this one I implement a Javascript client for the API built in the first tutorial. Here you can see how the client authenticates. I used Knockout instead of Angular for the client, but the principles are the same.
这是编写服务器的另一种方法,它使用Flask-RESTful扩展来简化某些任务.
This one is another way to write the server, using the Flask-RESTful extension to simplify some tasks.
这是专门用于身份验证的教程.
This is a tutorial specifically dedicated to authentication.
我希望它们是有用的.
这篇关于使用angularjs和flask进行用户身份验证的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!