是否可以将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()