龙卷风的文摘与基本认证

tornado-http-auth的Python项目详细描述


Latest version released on PyPiApache License, Version 2.0.

Tornadoweb框架的摘要和基本身份验证。基于代码 还有来自Twisted的想法。

安装

最新稳定版本的tornado ansi标记可以从pypi安装:

$ pip install tornado-http-auth

用法

importtornado.ioloopfromtornado.webimportRequestHandler,Applicationfromtornado_http_authimportDigestAuthMixin,BasicAuthMixin,auth_requiredcredentials={'user1':'pass1'}# Example 1 (using decorator).classMainHandler(DigestAuthMixin,RequestHandler):@auth_required(realm='Protected',auth_func=credentials.get)defget(self):self.write('Hello %s'%self._current_user)# Example 2 (using prepare and get_authentciated_user).classMainHandler(BasicAuthMixin,RequestHandler):defprepare(self):self.get_authenticated_user(check_credentials_func=credentials.get,realm='Protected')defget(self):self.write('Hello %s'%self._current_user)app=Application([(r'/',MainHandler),])app.listen(8888)tornado.ioloop.IOLoop.current().start()# curl --user user1:pass1 -v http://localhost:8888  -> 200 OK# curl --user user2:pass2 -v http://localhost:8888  -> 401 Unauthorized# Remove or comment second class# curl --digest --user user1:pass1 -v http://localhost:8888  -> 200 OK# curl --digest --user user2:pass2 -v http://localhost:8888  -> 401 Unauthorized

许可证

这个项目是根据Apache License, Version 2.0的条款发布的。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
SpringWeb中的java更新/通知其他用户   java Lambda性能测试   java Bukkit插件:空白符号   java在按下按钮后改变彩色正方形的大小   javajavac相当于“D”?   java序列化接口   属性无法从属性文件返回值   java我应该使用什么查询来使用Jsoup从html页面提取符号?   java Android Studio项目结构问题   JAVA方法和返回值/公共变量(基础)   java将NativeQuery映射到POJO   java如何在下面的程序中消除NumberFormatException?   在java中获取链表与数组中的对象   java Android Firebase将用户发送到聊天室