Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
144
Merge Requests
144
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
cbf5deb4
Commit
cbf5deb4
authored
Aug 19, 2016
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_oauth_google_login: Initial implementation of login in ERP5 with Google Account
parent
7b9c2be7
Changes
35
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
1382 additions
and
12 deletions
+1382
-12
bt5/erp5_oauth_google_login/ActionTemplateItem/portal_types/Google%20Login/view.xml
...n/ActionTemplateItem/portal_types/Google%20Login/view.xml
+85
-0
bt5/erp5_oauth_google_login/ActionTemplateItem/portal_types/System%20Preference/google_preference_view.xml
...rtal_types/System%20Preference/google_preference_view.xml
+85
-0
bt5/erp5_oauth_google_login/ExtensionTemplateItem/portal_components/extension.erp5.GoogleLoginUtility.py
...em/portal_components/extension.erp5.GoogleLoginUtility.py
+55
-0
bt5/erp5_oauth_google_login/ExtensionTemplateItem/portal_components/extension.erp5.GoogleLoginUtility.xml
...m/portal_components/extension.erp5.GoogleLoginUtility.xml
+123
-0
bt5/erp5_oauth_google_login/PathTemplateItem/portal_caches/google_server_auth_token_cache_factory.xml
.../portal_caches/google_server_auth_token_cache_factory.xml
+74
-0
bt5/erp5_oauth_google_login/PathTemplateItem/portal_caches/google_server_auth_token_cache_factory/volatile_cache_plugin.xml
...server_auth_token_cache_factory/volatile_cache_plugin.xml
+20
-0
bt5/erp5_oauth_google_login/PortalTypeTemplateItem/portal_types/Google%20Login.xml
...in/PortalTypeTemplateItem/portal_types/Google%20Login.xml
+76
-0
bt5/erp5_oauth_google_login/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
...rtalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
+6
-0
bt5/erp5_oauth_google_login/PropertySheetTemplateItem/portal_property_sheets/GoogleOAuthPreference.xml
...lateItem/portal_property_sheets/GoogleOAuthPreference.xml
+66
-0
bt5/erp5_oauth_google_login/PropertySheetTemplateItem/portal_property_sheets/GoogleOAuthPreference/preferred_google_client_id_property.xml
...leOAuthPreference/preferred_google_client_id_property.xml
+38
-0
bt5/erp5_oauth_google_login/PropertySheetTemplateItem/portal_property_sheets/GoogleOAuthPreference/preferred_google_secret_key_property.xml
...eOAuthPreference/preferred_google_secret_key_property.xml
+38
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login.xml
...SkinTemplateItem/portal_skins/erp5_oauth_google_login.xml
+26
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/Base_createOauth2User.py
...al_skins/erp5_oauth_google_login/Base_createOauth2User.py
+63
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/Base_createOauth2User.xml
...l_skins/erp5_oauth_google_login/Base_createOauth2User.xml
+62
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_getAccessTokenFromCode.xml
...p5_oauth_google_login/ERP5Site_getAccessTokenFromCode.xml
+28
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_getGoogleUserId.xml
...kins/erp5_oauth_google_login/ERP5Site_getGoogleUserId.xml
+28
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_receiveGoogleCallback.py
...erp5_oauth_google_login/ERP5Site_receiveGoogleCallback.py
+32
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_receiveGoogleCallback.xml
...rp5_oauth_google_login/ERP5Site_receiveGoogleCallback.xml
+62
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_redirectToGoogleLoginPage.py
..._oauth_google_login/ERP5Site_redirectToGoogleLoginPage.py
+11
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_redirectToGoogleLoginPage.xml
...oauth_google_login/ERP5Site_redirectToGoogleLoginPage.xml
+62
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/SystemPreference_viewGoogleOAuthPreference.xml
...ogle_login/SystemPreference_viewGoogleOAuthPreference.xml
+132
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/SystemPreference_viewGoogleOAuthPreference/my_preferred_google_client_id.xml
...ewGoogleOAuthPreference/my_preferred_google_client_id.xml
+84
-0
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/SystemPreference_viewGoogleOAuthPreference/my_preferred_google_secret_key.xml
...wGoogleOAuthPreference/my_preferred_google_secret_key.xml
+84
-0
bt5/erp5_oauth_google_login/bt/dependency_list
bt5/erp5_oauth_google_login/bt/dependency_list
+1
-0
bt5/erp5_oauth_google_login/bt/template_action_path_list
bt5/erp5_oauth_google_login/bt/template_action_path_list
+2
-0
bt5/erp5_oauth_google_login/bt/template_extension_id_list
bt5/erp5_oauth_google_login/bt/template_extension_id_list
+1
-0
bt5/erp5_oauth_google_login/bt/template_format_version
bt5/erp5_oauth_google_login/bt/template_format_version
+1
-0
bt5/erp5_oauth_google_login/bt/template_path_list
bt5/erp5_oauth_google_login/bt/template_path_list
+2
-0
bt5/erp5_oauth_google_login/bt/template_portal_type_id_list
bt5/erp5_oauth_google_login/bt/template_portal_type_id_list
+1
-0
bt5/erp5_oauth_google_login/bt/template_portal_type_workflow_chain_list
..._google_login/bt/template_portal_type_workflow_chain_list
+2
-0
bt5/erp5_oauth_google_login/bt/template_property_sheet_id_list
...rp5_oauth_google_login/bt/template_property_sheet_id_list
+1
-0
bt5/erp5_oauth_google_login/bt/template_skin_id_list
bt5/erp5_oauth_google_login/bt/template_skin_id_list
+1
-0
bt5/erp5_oauth_google_login/bt/title
bt5/erp5_oauth_google_login/bt/title
+1
-0
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/login_form.zpt
...TemplateItem/portal_skins/erp5_xhtml_style/login_form.zpt
+9
-0
product/ERP5Security/ERP5ExternalOauth2ExtractionPlugin.py
product/ERP5Security/ERP5ExternalOauth2ExtractionPlugin.py
+20
-12
No files found.
bt5/erp5_oauth_google_login/ActionTemplateItem/portal_types/Google%20Login/view.xml
0 → 100644
View file @
cbf5deb4
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ActionInformation"
module=
"Products.CMFCore.ActionInformation"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
action_type/object_view
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
category
</string>
</key>
<value>
<string>
object_view
</string>
</value>
</item>
<item>
<key>
<string>
condition
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
icon
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
view
</string>
</value>
</item>
<item>
<key>
<string>
permissions
</string>
</key>
<value>
<tuple>
<string>
View
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Action Information
</string>
</value>
</item>
<item>
<key>
<string>
priority
</string>
</key>
<value>
<float>
1.0
</float>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
View
</string>
</value>
</item>
<item>
<key>
<string>
visible
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"Expression"
module=
"Products.CMFCore.Expression"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
text
</string>
</key>
<value>
<string>
string:${object_url}/Login_view
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/ActionTemplateItem/portal_types/System%20Preference/google_preference_view.xml
0 → 100644
View file @
cbf5deb4
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ActionInformation"
module=
"Products.CMFCore.ActionInformation"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
action_type/object_view
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
category
</string>
</key>
<value>
<string>
object_view
</string>
</value>
</item>
<item>
<key>
<string>
condition
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
icon
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
google_preference_view
</string>
</value>
</item>
<item>
<key>
<string>
permissions
</string>
</key>
<value>
<tuple>
<string>
View
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Action Information
</string>
</value>
</item>
<item>
<key>
<string>
priority
</string>
</key>
<value>
<float>
20.0
</float>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Google OAuth
</string>
</value>
</item>
<item>
<key>
<string>
visible
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"Expression"
module=
"Products.CMFCore.Expression"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
text
</string>
</key>
<value>
<string>
string:${object_url}/SystemPreference_viewGoogleOAuthPreference
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/ExtensionTemplateItem/portal_components/extension.erp5.GoogleLoginUtility.py
0 → 100644
View file @
cbf5deb4
import
httplib
import
urllib
import
json
import
httplib2
import
apiclient.discovery
import
oauth2client.client
import
socket
def
getAccessTokenFromCode
(
self
,
code
,
redirect_uri
):
connection_kw
=
{
'host'
:
'accounts.google.com'
,
'timeout'
:
30
}
connection
=
httplib
.
HTTPSConnection
(
**
connection_kw
)
data
=
{
'client_id'
:
self
.
portal_preferences
.
getPreferredGoogleClientId
(),
'client_secret'
:
self
.
portal_preferences
.
getPreferredGoogleSecretKey
(),
'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
()
status
=
response
.
status
if
status
!=
200
:
return
status
,
None
try
:
body
=
json
.
loads
(
response
.
read
())
except
Exception
:
return
status
,
None
try
:
return
status
,
body
except
Exception
:
return
status
,
None
def
getUserId
(
access_token
):
timeout
=
socket
.
getdefaulttimeout
()
try
:
socket
.
setdefaulttimeout
(
10
)
http
=
oauth2client
.
client
.
AccessTokenCredentials
(
access_token
,
'ERP5'
).
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
\ No newline at end of file
bt5/erp5_oauth_google_login/ExtensionTemplateItem/portal_components/extension.erp5.GoogleLoginUtility.xml
0 → 100644
View file @
cbf5deb4
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Extension Component"
module=
"erp5.portal_type"
/>
</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>
GoogleLoginUtility
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
extension.erp5.GoogleLoginUtility
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Extension Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<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>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/PathTemplateItem/portal_caches/google_server_auth_token_cache_factory.xml
0 → 100644
View file @
cbf5deb4
<?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>
<string>
google_server_auth_token_cache_factory
</string>
</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>
bt5/erp5_oauth_google_login/PathTemplateItem/portal_caches/google_server_auth_token_cache_factory/volatile_cache_plugin.xml
0 → 100644
View file @
cbf5deb4
<?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>
bt5/erp5_oauth_google_login/PortalTypeTemplateItem/portal_types/Google%20Login.xml
0 → 100644
View file @
cbf5deb4
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Base Type"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
content_icon
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
group_list
</string>
</key>
<value>
<tuple>
<string>
login
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Google Login
</string>
</value>
</item>
<item>
<key>
<string>
init_script
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
permission
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Base Type
</string>
</value>
</item>
<item>
<key>
<string>
searchable_text_property_id
</string>
</key>
<value>
<tuple>
<string>
reference
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
type_class
</string>
</key>
<value>
<string>
Login
</string>
</value>
</item>
<item>
<key>
<string>
type_interface
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
type_mixin
</string>
</key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
0 → 100644
View file @
cbf5deb4
<workflow_chain>
<chain>
<type>
Google Login
</type>
<workflow>
edit_workflow, validation_workflow
</workflow>
</chain>
</workflow_chain>
\ No newline at end of file
bt5/erp5_oauth_google_login/PropertySheetTemplateItem/portal_property_sheets/GoogleOAuthPreference.xml
0 → 100644
View file @
cbf5deb4
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Property Sheet"
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>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
GoogleOAuthPreference
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Property Sheet
</string>
</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>
bt5/erp5_oauth_google_login/PropertySheetTemplateItem/portal_property_sheets/GoogleOAuthPreference/preferred_google_client_id_property.xml
0 → 100644
View file @
cbf5deb4
<?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>
categories
</string>
</key>
<value>
<tuple>
<string>
elementary_type/string
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
preferred_google_client_id_property
</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>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/PropertySheetTemplateItem/portal_property_sheets/GoogleOAuthPreference/preferred_google_secret_key_property.xml
0 → 100644
View file @
cbf5deb4
<?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>
categories
</string>
</key>
<value>
<tuple>
<string>
elementary_type/string
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
preferred_google_secret_key_property
</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>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login.xml
0 → 100644
View file @
cbf5deb4
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Folder"
module=
"OFS.Folder"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_objects
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
erp5_oauth_google_login
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/Base_createOauth2User.py
0 → 100644
View file @
cbf5deb4
from
DateTime
import
DateTime
if
context
.
REQUEST
.
get
(
'Base_createOauth2User'
)
is
not
None
:
return
context
.
REQUEST
.
set
(
'Base_createOauth2User'
,
1
)
portal
=
context
.
getPortalObject
()
if
portal
.
portal_activities
.
countMessageWithTag
(
tag
)
>
0
:
return
person
=
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
(
reference
)
if
person
is
not
None
:
return
activate_kw
=
{
'tag'
:
tag
}
# In future we can move this script to another, because this script is generic enough
# to support Facebook login
if
reference
.
startswith
(
"go_"
):
portal_type
=
"Google Login"
elif
reference
.
startswith
(
"fb_"
):
portal_type
=
"Facebook Login"
else
:
raise
RuntimeError
(
"Impossible to select a portal type"
)
if
erp5_username
in
(
"Anonymous User"
,
None
):
person
=
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
,
first_name
=
first_name
,
last_name
=
last_name
,
default_email_coordinate_text
=
email
,
activate_kw
=
activate_kw
)
# Support erp5_credential
getDuration
=
getattr
(
portal
.
portal_preferences
,
"getPreferredCredentialAssignmentDuration"
,
None
)
assignment_duration
=
getDuration
and
getDuration
()
or
365
today
=
DateTime
()
delay
=
today
+
assignment_duration
# Support erp5_credential
getAssignmentCategoryList
=
getattr
(
portal
.
portal_preferences
,
"getPreferredSubscriptionAssignmentCategoryList"
,
None
)
category_list
=
getAssignmentCategoryList
and
getAssignmentCategoryList
()
or
[]
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
,
category_list
=
category_list
,
start_date
=
today
,
stop_date
=
delay
,
activate_kw
=
activate_kw
)
assignment
.
open
(
activate_kw
=
activate_kw
)
person
.
setRoleList
(
assignment
.
getRoleList
())
else
:
person
=
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
(
erp5_username
)
login
=
person
.
newContent
(
portal_type
=
portal_type
,
reference
=
reference
)
login
.
validate
(
activate_kw
=
activate_kw
)
if
person
.
getValidationState
()
!=
"validated"
:
person
.
validate
(
activate_kw
=
activate_kw
)
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/Base_createOauth2User.xml
0 → 100644
View file @
cbf5deb4
<?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>
_params
</string>
</key>
<value>
<string>
tag, first_name, last_name, reference, email, erp5_username=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_createOauth2User
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_getAccessTokenFromCode.xml
0 → 100644
View file @
cbf5deb4
<?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>
getAccessTokenFromCode
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
GoogleLoginUtility
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5Site_getAccessTokenFromCode
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_getGoogleUserId.xml
0 → 100644
View file @
cbf5deb4
<?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>
getUserId
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
GoogleLoginUtility
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5Site_getGoogleUserId
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_receiveGoogleCallback.py
0 → 100644
View file @
cbf5deb4
def
handleError
(
error
):
context
.
Base_redirect
(
'login_form'
,
keep_items
=
{
"portal_status_message"
:
context
.
Base_translateString
(
"There was problem with Google login: ${error}. Please try again later."
,
mapping
=
{
"error"
:
error
})
})
if
error
is
not
None
:
return
handleError
(
error
)
elif
code
is
not
None
:
portal
=
context
.
getPortalObject
()
status
,
response_dict
=
context
.
ERP5Site_getAccessTokenFromCode
(
code
,
"{0}/ERP5Site_receiveGoogleCallback"
.
format
(
portal
.
absolute_url
()))
if
status
!=
200
:
return
handleError
(
" "
.
join
([
"%s : %s"
%
(
k
,
v
)
for
k
,
v
in
response_dict
.
iteritems
()]))
if
response_dict
is
not
None
:
access_token
=
response_dict
[
'access_token'
].
encode
(
'utf-8'
)
response_dict
[
'login'
]
=
'go_'
+
context
.
ERP5Site_getGoogleUserId
(
access_token
)
response_dict
[
'erp5_username'
]
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserName
()
hash_str
=
context
.
Base_getHMAC
(
access_token
,
access_token
)
context
.
REQUEST
.
RESPONSE
.
setCookie
(
'__ac_google_hash'
,
hash_str
,
path
=
'/'
)
context
.
Base_setBearerToken
(
hash_str
,
response_dict
,
"google_server_auth_token_cache_factory"
)
return
context
.
REQUEST
.
RESPONSE
.
redirect
(
context
.
REQUEST
.
get
(
"came_from"
)
or
portal
.
absolute_url
())
return
handleError
(
''
)
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_receiveGoogleCallback.xml
0 → 100644
View file @
cbf5deb4
<?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>
_params
</string>
</key>
<value>
<string>
code=None, error=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5Site_receiveGoogleCallback
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_redirectToGoogleLoginPage.py
0 → 100644
View file @
cbf5deb4
from
ZTUtils
import
make_query
portal
=
context
.
getPortalObject
()
query
=
make_query
({
'response_type'
:
'code'
,
'client_id'
:
portal
.
portal_preferences
.
getPreferredGoogleClientId
(),
'redirect_uri'
:
"{0}/ERP5Site_receiveGoogleCallback"
.
format
(
portal
.
absolute_url
()),
'scope'
:
'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
})
context
.
REQUEST
.
RESPONSE
.
redirect
(
'''https://accounts.google.com/o/oauth2/auth?'''
+
query
)
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_redirectToGoogleLoginPage.xml
0 → 100644
View file @
cbf5deb4
<?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>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5Site_redirectToGoogleLoginPage
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/SystemPreference_viewGoogleOAuthPreference.xml
0 → 100644
View file @
cbf5deb4
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ERP5 Form"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_objects
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
Base_edit
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
edit_order
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
encoding
</string>
</key>
<value>
<string>
UTF-8
</string>
</value>
</item>
<item>
<key>
<string>
enctype
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
group_list
</string>
</key>
<value>
<list>
<string>
left
</string>
<string>
right
</string>
<string>
center
</string>
<string>
bottom
</string>
<string>
hidden
</string>
</list>
</value>
</item>
<item>
<key>
<string>
groups
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
bottom
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
center
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
hidden
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
left
</string>
</key>
<value>
<list>
<string>
my_preferred_google_client_id
</string>
<string>
my_preferred_google_secret_key
</string>
</list>
</value>
</item>
<item>
<key>
<string>
right
</string>
</key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SystemPreference_viewGoogleOAuthPreference
</string>
</value>
</item>
<item>
<key>
<string>
method
</string>
</key>
<value>
<string>
POST
</string>
</value>
</item>
<item>
<key>
<string>
name
</string>
</key>
<value>
<string>
Preference_viewGoogleOAuthPreference
</string>
</value>
</item>
<item>
<key>
<string>
pt
</string>
</key>
<value>
<string>
form_view
</string>
</value>
</item>
<item>
<key>
<string>
row_length
</string>
</key>
<value>
<int>
4
</int>
</value>
</item>
<item>
<key>
<string>
stored_encoding
</string>
</key>
<value>
<string>
UTF-8
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Google OAuth
</string>
</value>
</item>
<item>
<key>
<string>
unicode_mode
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
update_action
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
update_action_title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/SystemPreference_viewGoogleOAuthPreference/my_preferred_google_client_id.xml
0 → 100644
View file @
cbf5deb4
<?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_google_client_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>
</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>
</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>
title
</string>
</key>
<value>
<string>
Client ID
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/SystemPreference_viewGoogleOAuthPreference/my_preferred_google_secret_key.xml
0 → 100644
View file @
cbf5deb4
<?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_google_secret_key
</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>
</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>
</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>
title
</string>
</key>
<value>
<string>
Secret Key
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_oauth_google_login/bt/dependency_list
0 → 100644
View file @
cbf5deb4
erp5_bearer_token
\ No newline at end of file
bt5/erp5_oauth_google_login/bt/template_action_path_list
0 → 100644
View file @
cbf5deb4
Google Login | view
System Preference | google_preference_view
\ No newline at end of file
bt5/erp5_oauth_google_login/bt/template_extension_id_list
0 → 100644
View file @
cbf5deb4
extension.erp5.GoogleLoginUtility
\ No newline at end of file
bt5/erp5_oauth_google_login/bt/template_format_version
0 → 100644
View file @
cbf5deb4
1
\ No newline at end of file
bt5/erp5_oauth_google_login/bt/template_path_list
0 → 100644
View file @
cbf5deb4
portal_caches/google_server_auth_token_cache_factory
portal_caches/google_server_auth_token_cache_factory/**
\ No newline at end of file
bt5/erp5_oauth_google_login/bt/template_portal_type_id_list
0 → 100644
View file @
cbf5deb4
Google Login
\ No newline at end of file
bt5/erp5_oauth_google_login/bt/template_portal_type_workflow_chain_list
0 → 100644
View file @
cbf5deb4
Google Login | edit_workflow
Google Login | validation_workflow
\ No newline at end of file
bt5/erp5_oauth_google_login/bt/template_property_sheet_id_list
0 → 100644
View file @
cbf5deb4
GoogleOAuthPreference
\ No newline at end of file
bt5/erp5_oauth_google_login/bt/template_skin_id_list
0 → 100644
View file @
cbf5deb4
erp5_oauth_google_login
\ No newline at end of file
bt5/erp5_oauth_google_login/bt/title
0 → 100644
View file @
cbf5deb4
erp5_oauth_google_login
\ No newline at end of file
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/login_form.zpt
View file @
cbf5deb4
...
...
@@ -46,6 +46,15 @@
i18n:translate="" i18n:domain="ui">I forgot my password!</a>
</div>
</div>
<tal:block tal:condition="python: getattr(here.getPortalObject().portal_skins, 'erp5_oauth_google_login', None) is not None">
<div class="field">
<label> </label>
<div class="input">
<a tal:attributes="href string:${here/portal_url}/ERP5Site_redirectToGoogleLoginPage"
i18n:translate="" i18n:domain="ui">Login with Google</a>
</div>
</div>
</tal:block>
</fieldset>
<script type="text/javascript">setFocus()</script>
<p i18n:translate="" i18n:domain="ui">Having trouble logging in? Make sure to enable cookies in your web browser.</p>
...
...
product/ERP5Security/ERP5ExternalOauth2ExtractionPlugin.py
View file @
cbf5deb4
...
...
@@ -91,7 +91,7 @@ def addERP5GoogleExtractionPlugin(dispatcher, id, title=None, REQUEST=None):
class
ERP5ExternalOauth2ExtractionPlugin
:
cache_factory_name
=
'ext
re
nal_oauth2_token_cache_factory'
cache_factory_name
=
'ext
er
nal_oauth2_token_cache_factory'
security
=
ClassSecurityInfo
()
def
__init__
(
self
,
id
,
title
=
None
):
...
...
@@ -146,6 +146,14 @@ class ERP5ExternalOauth2ExtractionPlugin:
'No Base_createOauth2User script available, install '
'erp5_credential_oauth2, disabled authentication.'
)
return
DumbHTTPExtractor
().
extractCredentials
(
request
)
creds
,
user_dict
=
{
"login_portal_type"
:
self
.
login_portal_type
},
None
cookie_hash
=
request
.
get
(
self
.
cookie_name
)
if
cookie_hash
is
not
None
:
try
:
user_dict
=
self
.
getToken
(
cookie_hash
)
except
KeyError
:
LOG
(
self
.
getId
(),
INFO
,
'Hash %s not found'
%
cookie_hash
)
return
DumbHTTPExtractor
().
extractCredentials
(
request
)
creds
=
{}
token
=
None
...
...
@@ -174,10 +182,10 @@ class ERP5ExternalOauth2ExtractionPlugin:
# fallback to default way
return
DumbHTTPExtractor
().
extractCredentials
(
request
)
tag
=
'%s_user_creation_in_progress'
%
user
.
encode
(
'hex'
)
tag
=
'%s_user_creation_in_progress'
%
cookie_hash
.
encode
(
'hex'
)
if
self
.
getPortalObject
().
portal_activities
.
countMessageWithTag
(
tag
)
>
0
:
self
.
REQUEST
[
'USER_CREATION_IN_PROGRESS'
]
=
user
self
.
REQUEST
[
'USER_CREATION_IN_PROGRESS'
]
=
user
_dict
else
:
# create the user if not found
if
not
self
.
searchUsers
(
id
=
user
,
exact_match
=
True
):
...
...
@@ -185,11 +193,12 @@ class ERP5ExternalOauth2ExtractionPlugin:
if
sm
.
getUser
().
getId
()
!=
ERP5Security
.
SUPER_USER
:
newSecurityManager
(
self
,
self
.
getUser
(
ERP5Security
.
SUPER_USER
))
try
:
self
.
REQUEST
[
'USER_CREATION_IN_PROGRESS'
]
=
user
if
user_entry
is
None
:
user_entry
=
self
.
getUserEntry
(
token
)
self
.
REQUEST
[
'USER_CREATION_IN_PROGRESS'
]
=
user_dict
#if user_entry is None:
user_entry
=
self
.
getUserEntry
(
user_dict
)
user_entry
[
"erp5_username"
]
=
user_dict
.
get
(
"erp5_username"
)
try
:
self
.
Base_createOauth2User
(
tag
,
**
user_entry
)
Base_createOauth2User
(
tag
,
**
user_entry
)
except
Exception
:
LOG
(
'ERP5ExternalOauth2ExtractionPlugin'
,
ERROR
,
'Issue while calling creation script:'
,
error
=
True
)
...
...
@@ -257,7 +266,7 @@ class ERP5GoogleExtractionPlugin(ERP5ExternalOauth2ExtractionPlugin, BasePlugin)
prefix
=
'go_'
header_string
=
'google'
def
getUserEntry
(
self
,
token
):
def
getUserEntry
(
self
,
user_dict
):
if
httplib2
is
None
:
LOG
(
'ERP5GoogleExtractionPlugin'
,
INFO
,
'No Google modules available, please install google-api-python-client '
...
...
@@ -267,7 +276,8 @@ class ERP5GoogleExtractionPlugin(ERP5ExternalOauth2ExtractionPlugin, BasePlugin)
try
:
# require really fast interaction
socket
.
setdefaulttimeout
(
5
)
http
=
oauth2client
.
client
.
AccessTokenCredentials
(
token
,
'ERP5 Client'
http
=
oauth2client
.
client
.
AccessTokenCredentials
(
user_dict
[
"access_token"
],
'ERP5 Client'
).
authorize
(
httplib2
.
Http
())
service
=
apiclient
.
discovery
.
build
(
"oauth2"
,
"v1"
,
http
=
http
)
google_entry
=
service
.
userinfo
().
get
().
execute
()
...
...
@@ -282,14 +292,12 @@ class ERP5GoogleExtractionPlugin(ERP5ExternalOauth2ExtractionPlugin, BasePlugin)
try
:
for
k
in
((
'first_name'
,
'given_name'
),
(
'last_name'
,
'family_name'
),
(
'reference'
,
'id'
),
(
'email'
,
'email'
)):
value
=
google_entry
[
k
[
1
]].
encode
(
'utf-8'
)
if
k
[
0
]
==
'reference'
:
value
=
self
.
prefix
+
value
user_entry
[
k
[
0
]]
=
value
except
KeyError
:
user_entry
=
None
user_entry
[
"reference"
]
=
user_dict
[
"login"
]
return
user_entry
#List implementation of class
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment