CherryPy wsgi基本的http身份验证

时间:2012-12-15 19:50:07

标签: python cherrypy http-basic-authentication

是否可以将cherrypy.lib.auth_basic的方法用于CherryPyWSGIServer对象?

即使我调用cherrypy.config.update函数来包含允许的用户列表,客户端仍然可以访问和使用该应用程序而无需任何身份验证凭据。

    from soaplib.core import Application
    from cherrypy import wsgiserver
    import cherrypy
    from cherrypy.wsgiserver import CherryPyWSGIServer

    userpassdict = {'bird' : 'bebop', 'ornette' : 'wayout'}
    checkpassword = cherrypy.lib.auth_basic.checkpassword_dict(userpassdict)
    basic_auth = {'tools.auth_basic.on': True,
                    'tools.auth_basic.realm': 'earth',
                    'tools.auth_basic.checkpassword': checkpassword,
    }
    app_config = { '/' : basic_auth }
    cherrypy.config.update(app_config)

    #initialize service
    soap_app = Application([MySoapMethods], tns, app_name);
    wsgi_app = cherrypy.Application(soap_app);
    server = wsgiserver.CherryPyWSGIServer((server_addr, server_port), wsgi_app);
    server.start()

0 个答案:

没有答案