Skip to content

Commit

Permalink
Fixing documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonDel committed Nov 21, 2016
1 parent 670c443 commit 463dcdf
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 34 deletions.
58 changes: 33 additions & 25 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
xmlrpcssl
=========

**xmlprcssl** is a Python library that provides secure communication (`TLS <https://en.wikipedia.org/wiki/Transport_Layer_Security>`__) beetween clients and servers through xmlrpc protocol. It supports plugable handlers to provide user authentication. For now, it has as an example a ldap based authentication handler.
**xmlprcssl** is a Python library that provides secure communication \
(`TLS <https://en.wikipedia.org/wiki/Transport_Layer_Security>`__) beetween clients and servers \
through xmlrpc protocol. It supports plugable handlers to provide user authentication. For now, \
it has as an example a ldap based authentication handler.


Server configuration
Expand All @@ -27,44 +30,48 @@ Server configuration
>>> from xmlrpcssl import SecureAuthenticatedXMLRPCServer
>>> from xmlrpcssl.handlers import LdapVerifyingRequestHandler
>>> from datetime import datetime
>>> keySsl='/tmp/server.key'
>>> crtSsl='/tmp/server.crt'
>>> tcpPort=433
>>> serverIp='10.0.0.1'
>>> ldapHost = 'ldapHost' # User must have access granted to this host in ldap
>>> ldapServer = 'ldapServer' # ip or name of ldap server
>>> gidNumber = 111 # User must be in this group in order to be authenticated
>>> isMasterUser = False # True if the user has write permissions in the ldap server
>>> baseUsrLoginDn = 'o=Organization,c=US' # user base DN to perform login in
>>> KEY_SSL = '/tmp/server.key'
>>> CRT_SSL = '/tmp/server.crt'
>>> TCP_PORT = 433
>>> SERVER_IP = '10.0.0.1'
>>> LDAP_HOST = 'ldapHost' # User must have access granted to this host in ldap
>>> LDAP_SERVER = 'ldapServer' # ip or name of ldap server
>>> GIDNUMBER = 111 # User must be in this group in order to be authenticated
>>> IS_MASTER_USER = False # True if the user has write permissions in the ldap server
>>> BASE_USR_LOGIN_DN = 'o=Organization,c=US' # user base DN to perform login in
# the ldap server
>>> baseSearchDn = 'o=Organization,c=US' # search base DN to perform a search in
>>> BASE_SEARCH_DN = 'o=Organization,c=US' # search base DN to perform a search in
# the ldap server base
>>> RequestHandler = LdapVerifyingRequestHandler # a handler that inherits from
# BaseRequestHandler and performs user authentication
>>> optArgs={'isMasterUser':isMasterUser,'baseUsrLoginDn':baseUsrLoginDn,
... 'ldapServer':ldapServer,'gidNumber':gidNumber,'baseSearchDn':baseSearchDn,
... 'host':ldapHost,'RequestHandler':RequestHandler}
>>> serverSSL=SecureAuthenticatedXMLRPCServer((serverIp,tcpPort),keySsl,crtSsl,**optArgs)
>>> OPT_ARGS = {'isMasterUser': IS_MASTER_USER, 'baseUsrLoginDn': BASE_USR_LOGIN_DN,
... 'ldapServer': LDAP_SERVER, 'gidNumber': GIDNUMBER, 'baseSearchDn': BASE_SEARCH_DN,
... 'host': LDAP_HOST, 'RequestHandler': RequestHandler}
>>> server_ssl = SecureAuthenticatedXMLRPCServer((SERVER_IP, TCP_PORT), KEY_SSL,CRT_SSL,
... **OPT_ARGS)
>>> def test():
... # toy test function
... return datetime.now().strftime("%H:%M:%S")
>>> serverSSL.register_function(test)
>>> serverSSL.serve_forever()
>>> server_ssl.register_function(test)
>>> server_ssl.serve_forever()
Client configuration
--------------------

.. code:: python
>>> import ssl
>>> from xmlrpclib import ServerProxy
>>> userName = 'ldapUser'
>>> password = 'ldapUserPassword'
>>> tcpPort=433
>>> serverIp='10.0.0.1'
>>> clientXml=ServerProxy('https://'+userName+':'+password+'@'+serverIp+':'+str(tcpPort))
>>> response = clientXml.test()
>>> print response
>>> USERNAME = 'ldapUser'
>>> PASSWORD = 'ldapUserPassword'
>>> TCP_PORT = 433
>>> SERVER_IP = '10.0.0.1'
>>> client_xml = ServerProxy('https://'+USERNAME+':'+PASSWORD+'@'+SERVER_IP+':'+str(TCP_PORT),
context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))
>>> response = client_xml.test()
>>> print·response
Installation
------------
Expand Down Expand Up @@ -97,4 +104,5 @@ GPLv3 licensed.
Credits
-------

- http://code.activestate.com/recipes/496786-simple-xml-rpc-server-over-https and https://github.com/nosmo/python-xmlrpcssl for inspiration
Credits go to http://code.activestate.com/recipes/496786-simple-xml-rpc-server-over-https and \
https://github.com/nosmo/python-xmlrpcssl for inspiration.
6 changes: 3 additions & 3 deletions docs/source/xmlrpcssl.handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ xmlrpcssl.handlers package
Submodules
----------

xmlrpcssl.handlers.ldapHandler module
-------------------------------------
xmlrpcssl.handlers.ldap_handler module
--------------------------------------

.. automodule:: xmlrpcssl.handlers.ldapHandler
.. automodule:: xmlrpcssl.handlers.ldap_handler
:members:
:undoc-members:
:show-inheritance:
Expand Down
4 changes: 3 additions & 1 deletion examples/client_ldap_xmlrpc_ssl_example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from xmlrpclib import ServerProxy
import ssl

client_xml = ServerProxy('https://USER:PASSWORD@SERVER_XML-RPC_IP:TCP_PORT')
client_xml = ServerProxy('https://USER:PASSWORD@SERVER_XML-RPC_IP:TCP_PORT',
context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))
resp = client_xml.test()
print resp
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
author='Jonatan Dellagostin',
author_email='jdellagostin@gmail.com',
url='https://github.com/jonDel/xmlrpcssl',
packages=['xmlrpcssl'],
packages=['xmlrpcssl','xmlrpcssl/handlers'],
license='GPLv3',
description='xmlrpc server with basic authentication and secured with ssl',
classifiers=[
Expand Down
9 changes: 5 additions & 4 deletions xmlrpcssl/handlers/ldap_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ def verify_user_credentials(self):
Performs user authentication, by using the optional class object attributes,
(self.opt_args) in a ldap server. The following conditions must be true in order
to allow user access:
1. User login (self.opt_args['username'] and self.opt_args['password'])
2. User must belong to the configured access group(self.opt_args['gidNumber'])
3. User must have access to the configured host(self.opt_args['host']), which is
primarily intended to be the host where the xmlrpcssl server is running
1. User login (self.opt_args['username'] and self.opt_args['password'])
2. User must belong to the configured access group(self.opt_args['gidNumber'])
3. User must have access to the configured host(self.opt_args['host']), which is \
primarily intended to be the host where the xmlrpcssl server is running
'''
if not self.opt_args['username'] or not self.opt_args['password']:
Expand Down

0 comments on commit 463dcdf

Please sign in to comment.