oauth config wizard
bzr revid: al@openerp.com-20120818130411-auxfh3lc0r801kym
This commit is contained in:
parent
200a0fd5dd
commit
01c56cbb92
|
@ -17,7 +17,6 @@ class auth_oauth_provider(osv.osv):
|
|||
'enabled' : fields.boolean('Allowed'),
|
||||
'css_class' : fields.char('CSS class'),
|
||||
'body' : fields.char('Body'),
|
||||
'active' : fields.boolean('Active'),
|
||||
'sequence' : fields.integer(),
|
||||
}
|
||||
_defaults = {
|
||||
|
|
|
@ -28,51 +28,36 @@ class base_config_settings(osv.TransientModel):
|
|||
_inherit = 'base.config.settings'
|
||||
|
||||
_columns = {
|
||||
'auth_oauth_google_enabled' : fields.boolean('Allow users to login with Google'),
|
||||
'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 login with Facebook'),
|
||||
'auth_oauth_facebook_enabled' : fields.boolean('Allow users to sign in with Facebook'),
|
||||
'auth_oauth_facebook_client_id' : fields.char('Client ID'),
|
||||
}
|
||||
|
||||
def get_default_allow(self, cr, uid, fields, context=None):
|
||||
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]
|
||||
rg = self.pool.get('auth.oauth.provider').read(cr, uid, [google_id], ['enabled'], context=context)
|
||||
facebook_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_facebook')[1]
|
||||
rf = self.pool.get('auth.oauth.provider').read(cr, uid, [facebook_id], ['enabled'], context=context)
|
||||
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_facebook_enabled': rf[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_allow(self, cr, uid, ids, context=None):
|
||||
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)
|
||||
self.pool.get('auth.oauth.provider').write(cr, uid, [google_id], {'enabled':config.auth_oauth_google_enabled})
|
||||
self.pool.get('auth.oauth.provider').write(cr, uid, [facebook_id], {'enabled':config.auth_oauth_facebook_enabled})
|
||||
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)
|
||||
|
||||
# def get_default_client_ids(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]
|
||||
# return {
|
||||
# 'auth_oauth_google_client_id': icp.get_param(cr, uid, 'auth.auth_oauth_google_client_id', "Set by the user") or False
|
||||
# }
|
||||
|
||||
# def set_client_ids(self, cr, uid, ids, context=None):
|
||||
# provider_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_goole')
|
||||
|
||||
|
||||
# config = self.browse(cr, uid, ids[0], context=context)
|
||||
# icp = self.pool.get('ir.config_parameter')
|
||||
# icp.set_param(cr, uid, 'auth.google_client_id', config.google_client_id)
|
||||
|
||||
# def get_default_facebook_client_id(self, cr, uid, fields, context=None):
|
||||
# icp = self.pool.get('ir.config_parameter')
|
||||
# return {
|
||||
# 'facebook_client_id': icp.get_param(cr, uid, 'auth.facebook_client_id', "Set by the user") or False
|
||||
# }
|
||||
|
||||
# def set_facebook_client_id(self, cr, uid, ids, context=None):
|
||||
# config = self.browse(cr, uid, ids[0], context=context)
|
||||
# icp = self.pool.get('ir.config_parameter')
|
||||
# icp.set_param(cr, uid, 'auth.facebook_client_id', config.facebook_client_id)
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_general_configuration">
|
||||
<field name="name">base.config.settings.oauth</field>
|
||||
<field name="model">base.config.settings</field>
|
||||
|
@ -12,35 +11,34 @@
|
|||
<div name="google">
|
||||
<div>
|
||||
<field name="auth_oauth_google_enabled" class="oe_inline"/>
|
||||
<label for="auth_oauth_google_enabled"/>
|
||||
<label for="auth_oauth_google_enabled"/>
|
||||
</div>
|
||||
<div attrs="{'invisible':[('auth_oauth_google_enabled','=',False)]}">
|
||||
<div>
|
||||
<p>To setup the signin process with Google, first you have to perform the following steps:</p>
|
||||
<blockquote>
|
||||
To setup the signin process with Google, first you have to perform the following steps:<br/>
|
||||
<br/>
|
||||
1. Register your application through the Google's APIs console. The result of this registration is a set of values that are known to both Google and you application: 'client_id' and 'redirect_uri'.
|
||||
- Go to the <a href="https://code.google.com/apis/console/">Google APIs console</a><br/>
|
||||
- Ceate a new project<br/>
|
||||
- Go to Api Access<br/>
|
||||
- Create an oauth client_id<br/>
|
||||
- Edit settings and set both Authorized Redirect URIs and Authorized JavaScript Origins to your hostname.<br/>
|
||||
<br/>
|
||||
2. Fill the following field with the values assigned by Google.
|
||||
</div>
|
||||
<div>
|
||||
<label for="auth_oauth_google_client_id" placeholder="Your CLIENT_ID"/>
|
||||
<field name="auth_oauth_google_client_id" class="oe_inline"/>
|
||||
</div>
|
||||
Now copy paste the client_id here: <field name="auth_oauth_google_client_id" class="oe_inline" placeholder="e.g. 1234-xyz.apps.googleusercontent.com"/>
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
<div name="facebook">
|
||||
<div>
|
||||
<field name="auth_oauth_facebook_enabled" class="oe_inline"/>
|
||||
<label for="auth_oauth_facebook_enabled"/>
|
||||
<label for="auth_oauth_facebook_enabled"/>
|
||||
</div>
|
||||
<div attrs="{'invisible':[('auth_oauth_facebook_enabled','=',False)]}">
|
||||
<div>
|
||||
<label string="Here goes the explanation"/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="auth_oauth_facebook_client_id" placeholder="Your CLIENT_ID"/>
|
||||
<field name="auth_oauth_facebook_client_id" class="oe_inline"/>
|
||||
</div>
|
||||
<div attrs="{'invisible':[('auth_oauth_facebook_enabled','=',False)]}">
|
||||
<blockquote>
|
||||
To setup the signin process with Google, first you have to perform the following steps:<br/>
|
||||
<br/>
|
||||
Now copy paste the client_id here: <field name="auth_oauth_facebook_client_id" class="oe_inline" placeholder="e.g. 1234-xyz.apps.googleusercontent.com"/>
|
||||
</blockquote>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -49,4 +47,4 @@
|
|||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
|
|
@ -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 uninvited users to 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):
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
<field name="inherit_id" ref="base_setup.view_general_configuration"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='module_auth_anonymous']/.." position="after">
|
||||
<div>
|
||||
<field name="auth_signup_uninvited" class="oe_inline"/>
|
||||
<label for="auth_signup_uninvited"/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="auth_signup_template_user_id"/>
|
||||
<field name="auth_signup_template_user_id" class="oe_inline"/>
|
||||
|
|
|
@ -30,9 +30,9 @@ class base_config_settings(osv.osv_memory):
|
|||
This installs the module multi_company."""),
|
||||
'module_share': fields.boolean('allow documents sharing',
|
||||
help="""Share or embbed any screen of openerp."""),
|
||||
'module_portal': fields.boolean('activate customer portal',
|
||||
'module_portal': fields.boolean('activate the customer/supplier portal',
|
||||
help="""Give access your customers and suppliers to their documents."""),
|
||||
'module_auth_anonymous': fields.boolean('public website',
|
||||
'module_auth_anonymous': fields.boolean('activete the public portal',
|
||||
help="""Enable the public part of openerp, the public part of openerp are browsable like a website."""),
|
||||
'module_auth_oauth': fields.boolean('use external authentication providers, sign in with google, facebook, ...'),
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
{
|
||||
'name' : "Portal",
|
||||
'version' : "1.0",
|
||||
'depends' : ["base", "share", "auth_anonymous"],
|
||||
'depends' : ["base", "share", "auth_signup" "auth_anonymous"],
|
||||
'author' : "OpenERP SA",
|
||||
'category': 'Portal',
|
||||
'description': """
|
||||
|
|
Loading…
Reference in New Issue