[Erp5-report] r38584 fx.algrain - /experimental/bt5/erp5_credential/SkinTemplateItem/portal...

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Sep 23 12:18:35 CEST 2010


Author: fx.algrain
Date: Thu Sep 23 12:18:33 2010
New Revision: 38584

URL: http://svn.erp5.org?rev=38584&view=rev
Log:
ERP5 Credential can be used on tiolive instance with SSO

Added:
    experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_isSingleSignOnEnable.xml
    experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/WizardTool_isValidUserName.xml
Modified:
    experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml
    experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_createUser.xml

Modified: experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml?rev=38584&r1=38583&r2=38584&view=diff
==============================================================================
--- experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml [utf8] (original)
+++ experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml [utf8] Thu Sep 23 12:18:33 2010
@@ -52,7 +52,7 @@
             <key> <string>_body</string> </key>
             <value> <string encoding="cdata"><![CDATA[
 
-"""Check if login is avaible or not.\n
+"""Check login is available locally and globally for instance with SSO.\n
 Parameters:\n
 value -- field value (string)\n
 RESQEST -- standard REQUEST variable"""\n
@@ -88,8 +88,22 @@ credential_request_count_result = module
 if credential_request_count_result[0][0] > 0:\n
   return False\n
 \n
+#check local account\n
+if not context.ERP5Site_isLocalLoginAvailable(value):\n
+  return False\n
+\n
+if context.ERP5Site_isSingleSignOnEnable():\n
+  #check username syntaxe\n
+  if not context.WizardTool_isValidUserName(value):\n
+    return False\n
+\n
+  #check username is unique\n
+  if not context.WizardTool_isPersonReferenceGloballyUnique(editor=value,\n
+                                                   request=REQUEST, \n
+                                                   ignore_users_from_same_instance=0):\n
+    return False\n
 \n
-return context.ERP5Site_isLocalLoginAvailable(value)\n
+return True\n
 
 
 ]]></string> </value>

Modified: experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_createUser.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_createUser.xml?rev=38584&r1=38583&r2=38584&view=diff
==============================================================================
--- experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_createUser.xml [utf8] (original)
+++ experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_createUser.xml [utf8] Thu Sep 23 12:18:33 2010
@@ -50,7 +50,9 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>"""Just set reference and password to create a user"""\n
+            <value> <string>"""Set reference and password to create a user. Create a global user if SSO enable.\n
+Proxy:\n
+Manager -- allow to set password on all account"""\n
 person = context.getDestinationDecisionValue(portal_type="Person")\n
 \n
 #Create user of the person only if not exist\n
@@ -59,17 +61,40 @@ if person.hasReference() and person.getP
 \n
 #Set login\n
 login = context.getReference()\n
-person.setReference(login)\n
+if not person.hasReference():\n
+  if not login:\n
+    raise ValueError, "Impossible to create an account without login"\n
+  person.setReference(login)\n
+else:\n
+  login = person.getReference()\n
 \n
-#Set password\n
-if context.getPassword():\n
-  #User has fill a password\n
-  password = None\n
-  person.setEncodedPassword(context.getPassword())\n
+password = None\n
+#Set password if no password on the person\n
+if not person.getPassword() :\n
+\n
+  if context.getPassword():\n
+    #User has fill a password\n
+    password = context.getPassword()\n
+    person.setEncodedPassword(password)\n
+\n
+  else:\n
+    #We should generate a password\n
+    password = context.Person_generatePassword(alpha=5, numeric=3)\n
+    person.setPassword(password)\n
+\n
+  # create a global account\n
+  if context.ERP5Site_isSingleSignOnEnable():\n
+    #The master manage encoded password and clear password\n
+    context.Person_createNewGlobalUserAccount(password=password)\n
 else:\n
-  #We should generate a password\n
-  password = Person_generatePassword()\n
-  person.setPassword(password)\n
+  #Person has an already an account\n
+  if context.ERP5Site_isSingleSignOnEnable():\n
+    #Check assignment for the current instance\n
+    context.Person_validateGlobalUserAccount()\n
+\n
+if password.startswith(\'{SSHA}\'):\n
+  #password is encoded, set it to None to script witch send the password to user\n
+  password = None\n
 \n
 return login, password\n
 </string> </value>
@@ -121,8 +146,8 @@ return login, password\n
                             <string>person</string>
                             <string>None</string>
                             <string>login</string>
+                            <string>ValueError</string>
                             <string>password</string>
-                            <string>Person_generatePassword</string>
                           </tuple>
                         </value>
                     </item>

Added: experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_isSingleSignOnEnable.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_isSingleSignOnEnable.xml?rev=38584&view=auto
==============================================================================
--- experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_isSingleSignOnEnable.xml (added)
+++ experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_isSingleSignOnEnable.xml [utf8] Thu Sep 23 12:18:33 2010
@@ -0,0 +1,139 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_body</string> </key>
+            <value> <string>"""Check if we have sso or not (master/slave or nor)\n
+Proxy:\n
+Manager -- Be sure to be able to check is SSO enable"""\n
+#TODO: Improve this and add it in introspection tool\n
+\n
+try:\n
+  context.portal_wizard\n
+  return True\n
+except AttributeError:\n
+  return False\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>_proxy_roles</string> </key>
+            <value>
+              <tuple>
+                <string>Manager</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>errors</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_code</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>co_argcount</string> </key>
+                        <value> <int>0</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>True</string>
+                            <string>AttributeError</string>
+                            <string>False</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>ERP5Site_isSingleSignOnEnable</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Added: experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/WizardTool_isValidUserName.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/WizardTool_isValidUserName.xml?rev=38584&view=auto
==============================================================================
--- experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/WizardTool_isValidUserName.xml (added)
+++ experimental/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/WizardTool_isValidUserName.xml [utf8] Thu Sep 23 12:18:33 2010
@@ -0,0 +1,132 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_body</string> </key>
+            <value> <string>""" Test on the master if user name is valid.\n
+Return 0 or 1.\n
+Parameter:\n
+user_name -- Login for authentication (string)\n
+\n
+TODO-Fx - Move to express_customisation_user_synchronization where we found\n
+          WizardTool_isPersonReferenceGloballyUnique...\n
+"""\n
+\n
+return context.portal_wizard.callRemoteProxyMethod(\n
+                  \'Base_isValidUserName\', \\\n
+                   use_cache = 0, \\\n
+                   user_name=user_name)\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>user_name</string> </value>
+        </item>
+        <item>
+            <key> <string>errors</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_code</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>co_argcount</string> </key>
+                        <value> <int>1</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>user_name</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>WizardTool_isValidUserName</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>




More information about the Erp5-report mailing list