Cha*_*lie 3 django basic-authentication spyne
如何在Django中使用Spyne的基本身份验证?我尝试了以下但它不起作用.我可以很好地查看WSDL页面文件,但每当我真正尝试将SayHello称为Web服务时,我都会收到403 FORBIDDEN响应.我相信403与CSRF有关,但csrf_exempt不应该让我解决这个问题吗?BTW,logged_in_or_basicauth来自这个片段:http://djangosnippets.org/snippets/243/.
class CapsWebService(ServiceBase):
@rpc(String, Integer, _returns=Iterable(String))
def SayHello(ctx, name, times):
for i in xrange(times):
yield 'Hello, %s' % name
caps_web_service = csrf_exempt(DjangoApplication(Application(
[CapsWebService], 'solutions.sfcs', in_protocol=Soap11(), out_protocol=Soap11(), interface=Wsdl11(),
)))
@logged_in_or_basicauth()
def foo_view(request):
logger.debug('views.foo_view()')
return caps_web_service(request)
Run Code Online (Sandbox Code Playgroud)
你可以试试
foo_view = csrf_exempt(foo_view)
Run Code Online (Sandbox Code Playgroud)
低于foo_view的定义.然后你不需要围绕另一个crsf_exempt
caps_web_service = DjangoApplication(Application(
[CapsWebService], 'solutions.sfcs', in_protocol=Soap11(), out_protocol=Soap11(), interface=Wsdl11(),
))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1380 次 |
| 最近记录: |