Restrict spyne SOAP service with oauth2_provider

隐身守侯 提交于 2019-12-12 04:37:27

问题


I need to restrict some of my SOAP method so they can only be accessible with an Access Token.

My SOAP service is running with Spyne and my OAuth2 provider comes from django-oauth2-toolkit.

from django.contrib.auth.decorators import login_required
from spyne.service import ServiceBase
from spyne.decorator import srpc, rpc
from oauth2_provider.views.generic import ProtectedResourceView

class SOAPService(ProtectedResourceView, ServiceBase):
  @rpc(Unicode, _returns=Unicode)
  @login_required()
  def HelloWorld(ctx, data):
    return "hello"

If I try to send a SOAP request to this function, I got an Error 500 with the following in Spyne's logs:

File "/Library/Python/2.7/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
if HelloWorld_func(request.user):

AttributeError: 'WsgiMethodContext' object has no attribute 'user'

I'm new to both SOAP and OAuth2 and I'm stuck on it. Do you have any clue or best practice on how to make OAuth2 provider check a SOAP access token on a Spyne service ?

来源:https://stackoverflow.com/questions/24268065/restrict-spyne-soap-service-with-oauth2-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!