Skip to content

Commit

Permalink
auth.AuthXMLRPCPoint class for making authenticated requests
Browse files Browse the repository at this point in the history
  • Loading branch information
lanzz committed Dec 9, 2013
1 parent d043837 commit 6585028
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions rpcenable/auth.py
Expand Up @@ -14,6 +14,7 @@
from django.conf import settings

from rpcenable.models import APIUser
from rpcenable.registry import XMLRPCPoint
from xmlrpclib import Fault

NONCE_MIN_LEN = 16
Expand Down Expand Up @@ -133,3 +134,15 @@ def wrapper(nonce, ts, username, signature, *args, **kwargs):
return f(None, *args, **kwargs)
return wrapper

class AuthXMLRPCPoint(XMLRPCPoint):
"""
XMLRPC endpoint for outgoing authenticated calls,
Automatically prepends the authentication arguments returned by
`generate_auth_args(user, secret)` to the list of XMLRPC
"""
def __init__ (self, user, secret, *args, **kwargs):
# pass down a function that prepends auth arguments to the regulart API Call args
kwargs['param_hook'] = lambda x: generate_auth_args(user, secret) + x
kwargs['allow_none'] = True
return XMLRPCPoint.__init__(self, *args, **kwargs) # old-style inheritance

0 comments on commit 6585028

Please sign in to comment.