first cherrypy skeleton for the onelab sso
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 29 Sep 2011 15:27:17 +0000 (17:27 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 29 Sep 2011 15:27:17 +0000 (17:27 +0200)
onelab-sso/NOTES [new file with mode: 0644]
onelab-sso/OnelabSingleSignOn.py [new file with mode: 0644]
onelab-sso/client.py [new file with mode: 0755]
onelab-sso/server.py [new file with mode: 0755]

diff --git a/onelab-sso/NOTES b/onelab-sso/NOTES
new file mode 100644 (file)
index 0000000..615b34a
--- /dev/null
@@ -0,0 +1,22 @@
+********** requirements
+requires cherrypy 3.x:
+. available in f14 with
+yum install python-cherrypy
+. available in macos with
+sudo port install py26-cherrypy3
+
+note that running https requires the OpenSSL module as well
+. f14
+yum install pyOpenSSL
+. macos
+???
+
+********** SSL
+on my devel box I created a fake cert using
+. openssl req -new -x509 -days 120 -set_serial $RANDOM -batch -subj "/CN=zankai.inria.fr" -nodes -keyout zankai.key -out zankai.crt
+
+worked like a charm 
+
+********** xmlrpc
+http://www.cherrypy.org/wiki/BuiltinTools#tools.xmlrpc
+http://tools.cherrypy.org/wiki/XmlRpcIntrospection
diff --git a/onelab-sso/OnelabSingleSignOn.py b/onelab-sso/OnelabSingleSignOn.py
new file mode 100644 (file)
index 0000000..64b916c
--- /dev/null
@@ -0,0 +1,17 @@
+import cherrypy
+
+interface_version='0.0'
+
+class OnelabSingleSignOn (cherrypy._cptools.XMLRPCController):
+    def version (self):
+        return interface_version
+    version.exposed=True
+
+    # basically this goes at several places to see if this user is known
+    # first sequential implementation should be ok for our needs
+    # given that we'd have only 2 places to check
+    # details of the return structure to be specified
+    def AuthCheck (self, login, password):
+        return { 'alt': "not implemented yet", }
+    AuthCheck.exposed=True
+
diff --git a/onelab-sso/client.py b/onelab-sso/client.py
new file mode 100755 (executable)
index 0000000..3ced7a4
--- /dev/null
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+import xmlrpclib
+import traceback
+
+url="https://localhost:9999/xmlrpc"
+try:
+    server = xmlrpclib.Server(url)
+    print url,'get version',server.version()
+    print url,'AuthCheck',server.AuthCheck("john.doe@foo.com","weirdpassword")
+except:
+    print 'something wrong with url=',url
+    traceback.print_exc()
diff --git a/onelab-sso/server.py b/onelab-sso/server.py
new file mode 100755 (executable)
index 0000000..10a3ab4
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+import cherrypy
+
+from OnelabSingleSignOn import OnelabSingleSignOn
+
+interface_path='/xmlrpc'
+mydir="/Users/parmentelat/git/infrastructure/onelab-sso/"
+
+cherrypy.tree.mount(OnelabSingleSignOn(), interface_path)
+
+tweaks={'xmlrpc_filter.on':True,
+        'request.dispatch': cherrypy.dispatch.XMLRPCDispatcher(),
+        }
+
+cherrypy.config.update( {interface_path: tweaks})
+
+cherrypy.server.socket_host=            '0.0.0.0'
+cherrypy.server.socket_port=            9999
+cherrypy.server.ssl_certificate=        mydir+"zankai.crt"
+cherrypy.server.ssl_private_key=        mydir+"zankai.key"
+
+cherrypy.server.start()