是否可以使用对象的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()