Commit 765ae78f authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Alain Takoudjou

slapos_web: BrowserID is dead, so drop unused code.

parent 1d4e3aed
......@@ -35,8 +35,7 @@ import apiclient.discovery
import httplib2
import oauth2client.client
import socket
from Products.ERP5Security.ERP5UserManager import getUserByLogin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
# common methods
def _getCacheFactory(self, cache_factory_name):
......@@ -180,50 +179,3 @@ def Google_checkUserExistence(self):
# user exist if server gave some correct response without waiting for user
return response.status in (200, 204)
# Browser ID
def BrowserID_setServerToken(self, key, body):
setServerToken(self, key, body, 'browser_id_auth_token_cache_factory')
def BrowserID_getServerToken(self, key):
return getServerToken(self, key, 'browser_id_auth_token_cache_factory')
def BrowserID_validateAssertion(self, assertion):
connection = httplib.HTTPSConnection(host='browserid.org', timeout=5)
data = urllib.urlencode({'assertion': assertion,
'audience': self.REQUEST.get('SERVER_URL')})
headers = {'Content-type': 'application/x-www-form-urlencoded'}
connection.request('POST', '/verify', data, headers)
response = connection.getresponse()
if response.status != 200:
return None
try:
body = json.loads(response.read())
except Exception:
return None
return body
@UnrestrictedMethod
def BrowserID_checkUserExistence(self):
hash = self.REQUEST.get('__ac_browser_id_hash')
try:
user_dict = BrowserID_getServerToken(self, hash)
except KeyError:
return False
user = user_dict['login']
tag = '%s_user_creation_in_progress' % user
person_list = getUserByLogin(self.getPortalObject(), user)
if len(person_list) == 0:
if self.getPortalObject().portal_activities.countMessageWithTag(tag) == 0:
user_entry = {'reference': user,
'email': user[4:],
'first_name': None,
'last_name': None}
self.Base_createOauth2User(tag, **user_entry)
return False
else:
return True
......@@ -6,10 +6,22 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>ViFiBWeb</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>extension.erp5.ViFiBWeb</string> </value>
......@@ -34,9 +46,8 @@
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W:143, 2: Redefining built-in \'hash\' (redefined-builtin)</string>
<string>W:164, 2: Redefining built-in \'hash\' (redefined-builtin)</string>
<string>W:212, 2: Redefining built-in \'hash\' (redefined-builtin)</string>
<string>W:142, 2: Redefining built-in \'hash\' (redefined-builtin)</string>
<string>W:163, 2: Redefining built-in \'hash\' (redefined-builtin)</string>
</tuple>
</value>
</item>
......@@ -47,13 +58,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -66,7 +92,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -75,7 +101,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>BrowserID_checkUserExistence</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ViFiBWeb</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BrowserID_checkUserExistence</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>BrowserID_setServerToken</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ViFiBWeb</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BrowserID_setServerToken</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>BrowserID_validateAssertion</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ViFiBWeb</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BrowserID_validateAssertion</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<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_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_viewBrowserIdLogin</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html>
<tal:block tal:define="website_url python: here.getWebSiteValue().absolute_url();
dummy python: request.RESPONSE.setCookie('redirect_after_login', context.REQUEST.form.get('callback_url', website_url), path='/');">
</tal:block>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script src="https://browserid.org/include.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {navigator.id.get(gotAssertion);
return false;});
function post_to_url(path, params, method) {
method = method || "post"; // Set method to post by default, if not specified.
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}
function gotAssertion(assertion) {
// got an assertion, now send it up to the server for verification
if (assertion !== null) {
post_to_url("https://www.slapos.org/login_with_browser_id/", {'assertion': assertion})
}
}
</script>
<body>
Waiting login ....
</body>
</html>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment