diff --git a/addons/auth_oauth/__init__.py b/addons/auth_oauth/__init__.py index c9acce48a16..a56db75633b 100644 --- a/addons/auth_oauth/__init__.py +++ b/addons/auth_oauth/__init__.py @@ -1,3 +1,4 @@ import controllers import auth_oauth import res_users +import res_config diff --git a/addons/auth_oauth/__openerp__.py b/addons/auth_oauth/__openerp__.py index 6c79bba2151..585dc48e11e 100644 --- a/addons/auth_oauth/__openerp__.py +++ b/addons/auth_oauth/__openerp__.py @@ -28,12 +28,13 @@ 'author': 'Victor Tabuenca', 'maintainer': 'OpenERP s.a.', 'website': 'http://www.openerp.com', - 'depends': ['base', 'web'], + 'depends': ['base', 'web', 'base_setup'], 'data': [ - 'auth_oauth_data.xml' + 'auth_oauth_data.xml', ], 'update_xml': [ - 'auth_oauth_view.xml' + 'auth_oauth_view.xml', + 'res_config.xml', ], 'js': [ 'static/src/js/auth_oauth.js', diff --git a/addons/auth_oauth/auth_oauth.py b/addons/auth_oauth/auth_oauth.py index e258505868d..34b6aa44936 100644 --- a/addons/auth_oauth/auth_oauth.py +++ b/addons/auth_oauth/auth_oauth.py @@ -1,6 +1,6 @@ from openerp.osv import osv, fields -class auth_oauth_providers(osv.osv): +class auth_oauth_provider(osv.osv): """Class defining the configuration values of an OAuth2 provider""" _name = 'auth.oauth.provider' @@ -8,15 +8,17 @@ class auth_oauth_providers(osv.osv): _order = 'name' _columns = { - 'name' : fields.char('Provider name', required=True), # Name of the OAuth2 entity, Google, LinkedIn, etc - 'client_id' : fields.char('Client ID', required=True), # Our identifier - 'auth_endpoint' : fields.char('Authentication URL', required=True), # OAuth provider URL to authenticate users + 'name' : fields.char('Provider name'), # Name of the OAuth2 entity, Google, LinkedIn, etc + 'client_id' : fields.char('Client ID'), # Our identifier + 'auth_endpoint' : fields.char('Authentication URL'), # OAuth provider URL to authenticate users 'scope' : fields.char('Scope'), # OAUth user data desired to access 'validation_endpoint' : fields.char('Validation URL'), # OAuth provider URL to validate tokens 'data_endpoint' : fields.char('Data URL'), + 'enabled' : fields.boolean('Allowed'), 'css_class' : fields.char('CSS class'), 'body' : fields.char('Body'), - 'active' : fields.boolean('Active'), 'sequence' : fields.integer(), } - + _defaults = { + 'enabled' : False, + } diff --git a/addons/auth_oauth/auth_oauth_data.xml b/addons/auth_oauth/auth_oauth_data.xml index 021a03b2742..7bb95192e5d 100644 --- a/addons/auth_oauth/auth_oauth_data.xml +++ b/addons/auth_oauth/auth_oauth_data.xml @@ -1,38 +1,34 @@ - + + Facebook Graph - facebook_client_id https://www.facebook.com/dialog/oauth https://graph.facebook.com/me/permissions zocial facebook Sign in with facebook - True Google OAuth2 - 108010644258-duuhmp6pu7li4tsmnqg7j9rvdeklg0ki.apps.googleusercontent.com https://accounts.google.com/o/oauth2/auth https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/oauth2/v1/tokeninfo https://www.googleapis.com/oauth2/v1/userinfo zocial google Sign in with google - True - - Twitter OAuth2 - 108010644258-duuhmp6pu7li4tsmnqg7j9rvdeklg0ki.apps.twitterusercontent.com + + diff --git a/addons/auth_oauth/auth_oauth_view.xml b/addons/auth_oauth/auth_oauth_view.xml index 678c347c84d..475720af9fd 100644 --- a/addons/auth_oauth/auth_oauth_view.xml +++ b/addons/auth_oauth/auth_oauth_view.xml @@ -11,7 +11,7 @@ - + @@ -22,7 +22,7 @@ - + auth.oauth.provider.list auth.oauth.provider @@ -31,7 +31,7 @@ - + diff --git a/addons/auth_oauth/controllers/main.py b/addons/auth_oauth/controllers/main.py index 28f550b4bda..2959fa45db1 100644 --- a/addons/auth_oauth/controllers/main.py +++ b/addons/auth_oauth/controllers/main.py @@ -18,7 +18,7 @@ class OAuthController(openerpweb.Controller): registry = openerp.modules.registry.RegistryManager.get(dbname) with registry.cursor() as cr: providers = registry.get('auth.oauth.provider') - l = providers.read(cr, 1, providers.search(cr, 1, [])) + l = providers.read(cr, 1, providers.search(cr, 1, [('enabled','=',True)])) return l @openerpweb.httprequest diff --git a/addons/auth_oauth/res_config.py b/addons/auth_oauth/res_config.py new file mode 100644 index 00000000000..82d79c767f5 --- /dev/null +++ b/addons/auth_oauth/res_config.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2012-Today OpenERP SA () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# +############################################################################## + +from openerp.osv import osv, fields + +import logging +_logger = logging.getLogger(__name__) + +class base_config_settings(osv.TransientModel): + _inherit = 'base.config.settings' + + _columns = { + 'auth_oauth_google_enabled' : fields.boolean('Allow users to sign in with Google'), + 'auth_oauth_google_client_id' : fields.char('Client ID'), + 'auth_oauth_facebook_enabled' : fields.boolean('Allow users to sign in with Facebook'), + 'auth_oauth_facebook_client_id' : fields.char('Client ID'), + } + + def get_oauth_providers(self, cr, uid, fields, context=None): + google_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_google')[1] + facebook_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_facebook')[1] + rg = self.pool.get('auth.oauth.provider').read(cr, uid, [google_id], ['enabled','client_id'], context=context) + rf = self.pool.get('auth.oauth.provider').read(cr, uid, [facebook_id], ['enabled','client_id'], context=context) + return { + 'auth_oauth_google_enabled': rg[0]['enabled'], + 'auth_oauth_google_client_id': rg[0]['client_id'], + 'auth_oauth_facebook_enabled': rf[0]['enabled'], + 'auth_oauth_facebook_client_id': rf[0]['client_id'], + } + + def set_oauth_providers(self, cr, uid, ids, context=None): + google_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_google')[1] + facebook_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_facebook')[1] + config = self.browse(cr, uid, ids[0], context=context) + rg = { + 'enabled':config.auth_oauth_google_enabled, + 'client_id':config.auth_oauth_google_client_id, + } + rf = { + 'enabled':config.auth_oauth_facebook_enabled, + 'client_id':config.auth_oauth_facebook_client_id, + } + self.pool.get('auth.oauth.provider').write(cr, uid, [google_id], rg) + self.pool.get('auth.oauth.provider').write(cr, uid, [facebook_id], rf) + diff --git a/addons/auth_oauth/res_config.xml b/addons/auth_oauth/res_config.xml new file mode 100644 index 00000000000..2b06e05327a --- /dev/null +++ b/addons/auth_oauth/res_config.xml @@ -0,0 +1,50 @@ + + + + + base.config.settings.oauth + base.config.settings + + + +
+
+
+ +
+
+
+ To setup the signin process with Google, first you have to perform the following steps:
+
+ - Go to the Google APIs console
+ - Ceate a new project
+ - Go to Api Access
+ - Create an oauth client_id
+ - Edit settings and set both Authorized Redirect URIs and Authorized JavaScript Origins to your hostname.
+
+ Now copy paste the client_id here: +
+
+
+
+
+ +
+
+
+ To setup the signin process with Google, first you have to perform the following steps:
+
+ Now copy paste the client_id here: +
+ +
+
+
+
+
+
+ +
+
diff --git a/addons/auth_signup/res_config.py b/addons/auth_signup/res_config.py index a9a490de8c5..6afd1c5b581 100644 --- a/addons/auth_signup/res_config.py +++ b/addons/auth_signup/res_config.py @@ -25,7 +25,8 @@ class base_config_settings(osv.TransientModel): _inherit = 'base.config.settings' _columns = { - 'auth_signup_template_user_id': fields.many2one('res.users', 'Template user for new users created through signup') + 'auth_signup_uninvited': fields.boolean('allow public users to sign up', help="If unchecked only invited users may sign up"), + 'auth_signup_template_user_id': fields.many2one('res.users', 'Template user for new users created through signup'), } def get_default_signup(self, cr, uid, fields, context=None): diff --git a/addons/auth_signup/res_config.xml b/addons/auth_signup/res_config.xml index 3bea8dc2aed..49669d36618 100644 --- a/addons/auth_signup/res_config.xml +++ b/addons/auth_signup/res_config.xml @@ -7,16 +7,15 @@ base.config.settings - - - + +
+ +
+
+
diff --git a/addons/base_setup/res_config.py b/addons/base_setup/res_config.py index 059a674e5f1..4826a50400d 100644 --- a/addons/base_setup/res_config.py +++ b/addons/base_setup/res_config.py @@ -28,10 +28,13 @@ class base_config_settings(osv.osv_memory): 'module_multi_company': fields.boolean('manage multiple companies', help="""Work in multi-company environments, with appropriate security access between companies. This installs the module multi_company."""), - 'module_portal': fields.boolean('activate customer portal', - help="""The portal will give access to a series of documents for your customers; his quotations, his invoices, his projects, etc."""), 'module_share': fields.boolean('allow documents sharing', - help="""As an example, you will be able to share a project or some tasks to your customers, or quotes/sales to several persons at your customer company, or your agenda availabilities to your contacts."""), + help="""Share or embbed any screen of openerp."""), + 'module_portal': fields.boolean('activate the customer/supplier portal', + help="""Give access your customers and suppliers to their documents."""), + 'module_auth_anonymous': fields.boolean('activate the public portal', + help="""Enable the public part of openerp, openerp becomes a public website."""), + 'module_auth_oauth': fields.boolean('use external authentication providers, sign in with google, facebook, ...'), } def open_company(self, cr, uid, ids, context=None): diff --git a/addons/base_setup/res_config_view.xml b/addons/base_setup/res_config_view.xml index fe0fc7d1254..512c0a3f52e 100644 --- a/addons/base_setup/res_config_view.xml +++ b/addons/base_setup/res_config_view.xml @@ -28,20 +28,34 @@
-