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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
erp5
Commits
0453a1a0
Commit
0453a1a0
authored
Nov 20, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oauth_google_login: inline getGoogleClientIdAndSecretKey
no need to expose this
parent
c79e5e64
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
90 deletions
+21
-90
bt5/erp5_oauth_google_login/ExtensionTemplateItem/portal_components/extension.erp5.GoogleLoginUtility.py
...em/portal_components/extension.erp5.GoogleLoginUtility.py
+21
-3
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_getGoogleClientIdAndSecretKey.py
...th_google_login/ERP5Site_getGoogleClientIdAndSecretKey.py
+0
-17
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_getGoogleClientIdAndSecretKey.xml
...h_google_login/ERP5Site_getGoogleClientIdAndSecretKey.xml
+0
-70
No files found.
bt5/erp5_oauth_google_login/ExtensionTemplateItem/portal_components/extension.erp5.GoogleLoginUtility.py
View file @
0453a1a0
...
@@ -5,8 +5,27 @@ from Products.ERP5Security.ERP5ExternalOauth2ExtractionPlugin import getGoogleUs
...
@@ -5,8 +5,27 @@ from Products.ERP5Security.ERP5ExternalOauth2ExtractionPlugin import getGoogleUs
SCOPE_LIST
=
[
'https://www.googleapis.com/auth/userinfo.profile'
,
SCOPE_LIST
=
[
'https://www.googleapis.com/auth/userinfo.profile'
,
'https://www.googleapis.com/auth/userinfo.email'
]
'https://www.googleapis.com/auth/userinfo.email'
]
def
_getGoogleClientIdAndSecretKey
(
portal
,
reference
=
"default"
):
"""Returns google client id and secret key.
Internal function.
"""
result_list
=
portal
.
portal_catalog
.
unrestrictedSearchResults
(
portal_type
=
"Google Connector"
,
reference
=
reference
,
validation_state
=
"validated"
,
limit
=
2
,
)
assert
result_list
,
"Google Connector not found"
if
len
(
result_list
)
==
2
:
raise
ValueError
(
"Impossible to select one Google Connector"
)
google_connector
=
result_list
[
0
].
getObject
()
return
google_connector
.
getClientId
(),
google_connector
.
getSecretKey
()
def
redirectToGoogleLoginPage
(
self
):
def
redirectToGoogleLoginPage
(
self
):
client_id
,
secret_key
=
self
.
ERP5Site_getGoogleClientIdAndSecretKey
(
)
client_id
,
secret_key
=
_getGoogleClientIdAndSecretKey
(
self
.
getPortalObject
()
)
flow
=
oauth2client
.
client
.
OAuth2WebServerFlow
(
flow
=
oauth2client
.
client
.
OAuth2WebServerFlow
(
client_id
=
client_id
,
client_id
=
client_id
,
client_secret
=
secret_key
,
client_secret
=
secret_key
,
...
@@ -18,8 +37,7 @@ def redirectToGoogleLoginPage(self):
...
@@ -18,8 +37,7 @@ def redirectToGoogleLoginPage(self):
self
.
REQUEST
.
RESPONSE
.
redirect
(
flow
.
step1_get_authorize_url
())
self
.
REQUEST
.
RESPONSE
.
redirect
(
flow
.
step1_get_authorize_url
())
def
getAccessTokenFromCode
(
self
,
code
,
redirect_uri
):
def
getAccessTokenFromCode
(
self
,
code
,
redirect_uri
):
portal
=
self
.
getPortalObject
()
client_id
,
secret_key
=
_getGoogleClientIdAndSecretKey
(
self
.
getPortalObject
())
client_id
,
secret_key
=
portal
.
ERP5Site_getGoogleClientIdAndSecretKey
()
flow
=
oauth2client
.
client
.
OAuth2WebServerFlow
(
flow
=
oauth2client
.
client
.
OAuth2WebServerFlow
(
client_id
=
client_id
,
client_id
=
client_id
,
client_secret
=
secret_key
,
client_secret
=
secret_key
,
...
...
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_getGoogleClientIdAndSecretKey.py
deleted
100644 → 0
View file @
c79e5e64
if
REQUEST
is
not
None
:
raise
ValueError
(
"This script can't be called in the URL"
)
result_list
=
context
.
getPortalObject
().
portal_catalog
(
portal_type
=
"Google Connector"
,
reference
=
reference
,
validation_state
=
"validated"
,
limit
=
2
,
)
assert
result_list
,
"Google Connector not found"
if
len
(
result_list
)
==
2
:
raise
ValueError
(
"Impossible to select one Google Connector"
)
google_connector
=
result_list
[
0
].
getObject
()
return
google_connector
.
getClientId
(),
google_connector
.
getSecretKey
()
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_getGoogleClientIdAndSecretKey.xml
deleted
100644 → 0
View file @
c79e5e64
<?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>
reference="default", REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5Site_getGoogleClientIdAndSecretKey
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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