changeset 3140:232b1fcfadab

OpenID RP: allow forcing a service for using OpenID as company-SSO
author Johannes Berg <johannes AT sipsolutions DOT net>
date Wed, 27 Feb 2008 15:32:33 +0100
parents 0c0fd7c894a3
children fe93fb0732a2
files MoinMoin/auth/openidrp.py
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/openidrp.py	Wed Feb 27 15:31:28 2008 +0100
+++ b/MoinMoin/auth/openidrp.py	Wed Feb 27 15:32:33 2008 +0100
@@ -25,11 +25,15 @@
 
     def __init__(self, modify_request=None,
                        update_user=None,
-                       create_user=None):
+                       create_user=None,
+                       forced_service=None):
         BaseAuth.__init__(self)
         self._modify_request = modify_request or (lambda x: None)
         self._update_user = update_user or (lambda i, u: None)
         self._create_user = create_user or (lambda i, u: None)
+        self._forced_service = forced_service
+        if forced_service:
+            self.login_inputs = ['special_no_input']
 
     def _handle_user_data(self, request, u):
         create = not u
@@ -237,8 +241,9 @@
             return ContinueLogin(user_obj)
 
         openid_id = kw.get('openid_identifier')
+
         # nothing entered? continue...
-        if not openid_id:
+        if not self._forced_service and not openid_id:
             return ContinueLogin(user_obj)
 
         _ = request.getText
@@ -252,7 +257,14 @@
                                         MoinOpenIDStore(request))
 
         try:
-            oidreq = oidconsumer.begin(openid_id)
+            fserv = self._forced_service
+            if fserv:
+                if isinstance(fserv, str) or isinstance(fserv, unicode):
+                    oidreq = oidconsumer.begin(fserv)
+                else:
+                    oidreq = oidconsumer.beginWithoutDiscovery(fserv)
+            else:
+                oidreq = oidconsumer.begin(openid_id)
         except HTTPFetchingError:
             return ContinueLogin(None, _('Failed to resolve OpenID.'))
         except DiscoveryFailure: