Commit 27398635 authored by Łukasz Nowak's avatar Łukasz Nowak

Implement Google authorisation.

parent af586aed
......@@ -52,7 +52,6 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
script.log(\'called\')\n
from DateTime import DateTime\n
\n
portal = context.getPortalObject()\n
......
466
\ No newline at end of file
467
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Cache Factory" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>cache_duration</string> </key>
<value> <int>3600</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>google_server_auth_token_cache_factory</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Cache Factory</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Ram Cache" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>volatile_cache_plugin</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Ram Cache</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Section" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>__translation_dict</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
<item>
<key> <string>custom_render_method_id</string> </key>
<value> <string>WebSection_googleInitiateLogin</string> </value>
</item>
<item>
<key> <string>default_page_displayed</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>login_with_google</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Section</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Login with Google</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<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="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<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="6" aka="AAAAAAAAAAY=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Section" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>custom_render_method_id</string> </key>
<value> <string>WebSection_googleCallbackLogin</string> </value>
</item>
<item>
<key> <string>default_page_displayed</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>google_callback</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Section</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Supports Google\'s callback</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>0</int> </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>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
94
\ No newline at end of file
95
\ No newline at end of file
......@@ -3,6 +3,8 @@ image_module/vifib.kvm
image_module/vifib.rack
portal_caches/facebook_server_auth_token_cache_factory
portal_caches/facebook_server_auth_token_cache_factory/volatile_cache_plugin
portal_caches/google_server_auth_token_cache_factory
portal_caches/google_server_auth_token_cache_factory/volatile_cache_plugin
web_page_module/vifib*
web_site_module/cash
web_site_module/cash/**
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Google application id.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_vifib_google_application_id_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: \'\'</string> </value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Facebook application secret.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_vifib_google_application_secret_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: \'\'</string> </value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -114,6 +114,8 @@
<string>my_preferred_vifib_facebook_application_id</string>
<string>my_preferred_vifib_facebook_application_secret</string>
<string>my_preferred_vifib_rest_api_login_check</string>
<string>my_preferred_vifib_google_application_id</string>
<string>my_preferred_vifib_google_application_secret</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_vifib_google_application_id</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Preferred Google Application Id</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_vifib_google_application_secret</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Preferred Google Application Secret</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
775
\ No newline at end of file
776
\ No newline at end of file
......@@ -29,7 +29,13 @@ import subprocess
import facebook
from Products.ERP5Type.Cache import DEFAULT_CACHE_SCOPE
import httplib
import urllib
import urlparse
import json
import apiclient.discovery
import httplib2
import oauth2client.client
import socket
def formatXml(self, xml):
"""Simple way to have nicely formatted XML"""
......@@ -78,10 +84,73 @@ def Facebook_getAccessTokenFromCode(self, code, redirect_uri):
app_id=self.portal_preferences.getPreferredVifibFacebookApplicationId(),
app_secret=self.portal_preferences.getPreferredVifibFacebookApplicationSecret())
# Google AS
def Google_setServerToken(self, key, body):
setServerToken(self, key, body, 'google_server_auth_token_cache_factory')
def Google_getServerToken(self, key):
return getServerToken(self, key, 'google_server_auth_token_cache_factory')
def Facebook_getAccessTokenFromCode(self, code, redirect_uri):
return facebook.get_access_token_from_code(code=code,
redirect_uri=redirect_uri,
app_id=self.portal_preferences.getPreferredVifibFacebookApplicationId(),
app_secret=self.portal_preferences.getPreferredVifibFacebookApplicationSecret())
def Google_getAccessTokenFromCode(self, code, redirect_uri):
connection_kw = {'host': 'accounts.google.com', 'timeout': 30}
connection = httplib.HTTPSConnection(**connection_kw)
data = {
'client_id': self.portal_preferences.getPreferredVifibGoogleApplicationId(),
'client_secret': self.portal_preferences.getPreferredVifibGoogleApplicationSecret(),
'grant_type': 'authorization_code',
'redirect_uri': redirect_uri,
'code': code
}
data = urllib.urlencode(data)
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "*/*"
}
connection.request('POST', '/o/oauth2/token', data, headers)
response = connection.getresponse()
if response.status != 200:
return None
try:
body = json.loads(response.read())
except Exception:
return None
try:
return body
except Exception:
return None
def Facebook_getUserId(access_token):
facebook_entry = facebook.GraphAPI(access_token).get_object("me")
return facebook_entry['id'].encode('utf-8')
def Google_getUserId(access_token):
# import ipdb ; ipdb.set_trace()
timeout = socket.getdefaulttimeout()
try:
# require really fast interaction
# socket.setdefaulttimeout(10)
http = oauth2client.client.AccessTokenCredentials(access_token, 'Vifib'
).authorize(httplib2.Http())
service = apiclient.discovery.build("oauth2", "v1", http=http)
google_entry = service.userinfo().get().execute()
except Exception:
google_entry = None
finally:
socket.setdefaulttimeout(timeout)
if google_entry is not None:
return google_entry['id'].encode('utf-8')
return None
def Facebook_checkUserExistence(self):
hash = self.REQUEST.get('__ac_facebook_hash')
try:
......@@ -90,7 +159,7 @@ def Facebook_checkUserExistence(self):
return False
access_token = access_token_dict.get('access_token')
url = urlparse.urlsplit(self.portal_preferences.getPreferredVifibRestApiLoginCheck())
connection_kw = {'host': url.netloc, 'timeout': 5}
connection_kw = {'host': url.netloc, 'timeout': 30}
if url.scheme == 'http':
connection = httplib.HTTPConnection(**connection_kw)
else:
......@@ -102,3 +171,24 @@ def Facebook_checkUserExistence(self):
# user exist if server gave some correct response without waiting for user
return response.status in (200, 204)
def Google_checkUserExistence(self):
hash = self.REQUEST.get('__ac_google_hash')
try:
access_token_dict = Google_getServerToken(self, hash)
except KeyError:
return False
access_token = access_token_dict.get('access_token')
url = urlparse.urlsplit(self.portal_preferences.getPreferredVifibRestApiLoginCheck())
connection_kw = {'host': url.netloc, 'timeout': 30}
if url.scheme == 'http':
connection = httplib.HTTPConnection(**connection_kw)
else:
connection = httplib.HTTPSConnection(**connection_kw)
connection.request('GET', url.path, headers = {
'Authorization' : 'Google %s' % access_token,
'Accept': 'application/json'})
response = connection.getresponse()
# user exist if server gave some correct response without waiting for user
return response.status in (200, 204)
<?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>Google_checkUserExistence</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ViFiBWeb</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Google_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>Google_getAccessTokenFromCode</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ViFiBWeb</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Google_getAccessTokenFromCode</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>Google_getServerToken</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ViFiBWeb</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Google_getServerToken</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>Google_getUserId</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ViFiBWeb</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Google_getUserId</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>Google_setServerToken</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ViFiBWeb</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Google_setServerToken</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -65,7 +65,7 @@ elif get(\'code\') is not None:\n
hash = context.Base_getHMAC(access_token, access_token)\n
context.REQUEST.RESPONSE.setCookie(\'__ac_facebook_hash\', hash, path=\'/\')\n
context.Facebook_setServerToken(hash, access_token_dict)\n
return context.Base_redirect(context.getWebSiteValue().absolute_url())\n
return context.REQUEST.RESPONSE.redirect(context.getWebSiteValue().absolute_url())\n
return handleError()\n
</string> </value>
</item>
......
<?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>get = context.REQUEST.get\n
\n
def handleError():\n
context.Base_redirect(\'login_form\', keep_items={"portal_status_message": "There was problem with Google login: %s. Please try again later." % get(\'error\')})\n
\n
if get(\'error\') is not None:\n
return handleError()\n
elif get(\'code\') is not None:\n
access_token_dict = context.Google_getAccessTokenFromCode(get(\'code\'), context.absolute_url())\n
if access_token_dict is not None:\n
access_token = access_token_dict[\'access_token\'].encode(\'utf-8\')\n
access_token_dict[\'login\'] = \'go_\' + context.Google_getUserId(access_token)\n
hash = context.Base_getHMAC(access_token, access_token)\n
context.REQUEST.RESPONSE.setCookie(\'__ac_google_hash\', hash, path=\'/\')\n
context.Google_setServerToken(hash, access_token_dict)\n
return context.REQUEST.RESPONSE.redirect(context.getWebSiteValue().absolute_url())\n
return handleError()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>code=None, error=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_googleCallbackLogin</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>from ZTUtils import make_query\n
query = make_query({\n
\'response_type\': \'code\',\n
\'client_id\': context.portal_preferences.getPreferredVifibGoogleApplicationId(),\n
\'redirect_uri\': context.google_callback.absolute_url(),\n
\'scope\': \'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email\'\n
})\n
\n
context.REQUEST.RESPONSE.redirect(\'\'\'https://accounts.google.com/o/oauth2/auth?\'\'\' + query)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_googleInitiateLogin</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -104,7 +104,8 @@
<key> <string>normal</string> </key>
<value>
<list>
<string>your_user_preparation</string>
<string>your_user_preparation_facebook</string>
<string>your_user_preparation_google</string>
</list>
</value>
</item>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_user_preparation</string> </value>
<value> <string>your_user_preparation_facebook</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -179,6 +179,7 @@ if REQUEST.has_key(\'portal_skin\'):\n
context.portal_skins.clearSkinCookie()\n
REQUEST.RESPONSE.expireCookie(\'__ac\', path=\'/\')\n
REQUEST.RESPONSE.expireCookie(\'__ac_facebook_hash\', path=\'/\')\n
REQUEST.RESPONSE.expireCookie(\'__ac_google_hash\', path=\'/\')\n
msg = context.Base_translateString(\'You have been logged out. Thank you for using this website.\')\n
return website.Base_redirect(form_id, keep_items = {\'portal_status_message\' : msg}, **kw)\n
</string> </value>
......
......@@ -65,7 +65,8 @@
tal:attributes="value request/came_from" />\n
<fieldset>\n
<div class="field nolabel validate widthAuto forgotten_password">\n
You can <a href="./login_with_facebook">login with with <img width="25px" src="./vifib_image/facebook_logo.png" alt="Facebook" title="Facebook"></a>, or use traditional methods below.\n
You can login with with <a href="./login_with_facebook"><img width="25px" src="./vifib_image/facebook_logo.png" alt="Facebook" title="Facebook"></a>,\n
with <a href="./login_with_google"><img src="./vifib_image/google_logo.png" alt="Google" title="Google"></a>, or use traditional methods below.\n
</div>\n
<div class="field login_name">\n
<label for="name" class="required" i18n:translate="" i18n:domain="ui">Name</label>\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Image" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts41840780.52</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>google_logo.png</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="base64">iVBORw0KGgoAAAANSUhEUgAAAEIAAAAXCAYAAAC/F5msAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ
bWFnZVJlYWR5ccllPAAACaVJREFUeNrcWAl0U1Uavu+9vKRJmqVpmyK2QlsKhdKpWCo7lB2RZVRG
RRYVhkEdRXEUNxwVGY8i23hkOc5URXQQxI2iB2UTmFJg2lKgLbSFtmmbpNmTl5e8/d55r1ooNSjL
mTk93nNuc+5//7u87///7/9vMfAL7da5e/qozdlZGBJxTAw0V30+p4r21iHQTVvaO+kZ1kGpLxm0
SRk2fyto+bJ2s7iJ2n41a7GugjHL7OMDIcOzYZ+3H0OFKgUmYMdUBotal5Abn5A80GCSzmBS5Iug
j37v/Gf9Hd0JCNyIm7WLjNPIQuPWSFkwILxGJcti6Zo2Gff4Xv2YF0JFfWY7veaCHY/KImMXFZUh
94PJiYW1takzPShxbKNT13dVv+7mFcZ/pkwx7EpF5MvGlmtZp1L+9Bv1GInMQ/c2nQ1n+6ren0HX
Lv93DF0xfObh7/R9Xhgm0jNPClTl5mjdsvruBgSEACCIAELXFsHtQKSMWPmGvUU1LGQ7/sQVQLh0
EOc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
Bmtv6Y3las3YQRGBUDAM06trUMmCneB12YiRmFkqf0s+YZ5QQmi0Gp1eOAe5wD3Nu7Jr2nFYFP88
CgsL271CrzoBRLAbbI1se0CXFH+7pHsjBVc90pPUkPFqNQzwvIOGUuAAF1r8M6vH9VoxDNf1X4xr
rNPxOKtFHacGBCm7AOQ4PuJsZSnPfyDjO8E73v4ecY11Cnl3pYRMTJ3VF4/reRoybXYkKDr8ryQe
xaoWuSu1jDfGnmDMs675rc3SIibktEZ8nlIoEhSmMt2lSbglVaXGw1FPTUHoeGHtVSQ5w0TcMMQA
CN1RSNe3AbHu157qSgVmUhLGT5fUXm96vZE2ZMEP+jHPBYvTZjT5tL2WjO5UGQKNZazBWHDsm4RC
OzINP/3NDf0v45feL0o9JHePwlXgR7f+v782IyBnbpsTnxZqrV7L2N453Nl6nP9gGGcqZkMxehYJ
/Mj/FRDdonnaYGrQJ8kFnykQaz5Y9RiFIaFeYt1Vv2kgBJpyCwwDSGP6opunlhu6zqdMtpnlDJYr
UiffvJFzsO4ORJwlX0P2Xr0T16ZN05q0bXoDfE9NhMowXMdQIXAb7QssYBy7X+eaXvnkNw1Eh+dq
01cXYnGps+Rk1E9+baoQ722VmMYDXMu6ryDb6LvRA/4rwAA8PdFYzR2ZFwAAAABJRU5ErkJggg==</string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>23</int> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>2563</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>66</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
389
\ No newline at end of file
390
\ 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