diff options
| author | Fabien Meghazi <fme@openerp.com> | 2012-09-24 10:44:33 +0200 |
|---|---|---|
| committer | Fabien Meghazi <fme@openerp.com> | 2012-09-24 10:44:33 +0200 |
| commit | 6875258258a1478dd1356fc7176a025cf8f00a5b (patch) | |
| tree | d203f9f536fa12ababffca0b22558a4768a0dbab | |
| parent | 3ed1ce8255a4afb2247c7c282173d7a0f01fc53c (diff) | |
[IMP] Wip oauth
bzr revid: fme@openerp.com-20120924084433-95rtadp5omhkc6x3
| -rw-r--r-- | addons/auth_oauth_provider/res_users.py | 11 | ||||
| -rw-r--r-- | addons/auth_oauth_provider/static/src/js/oauth_provider.js | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/addons/auth_oauth_provider/res_users.py b/addons/auth_oauth_provider/res_users.py index dd2178a1dff..3831a6a97d0 100644 --- a/addons/auth_oauth_provider/res_users.py +++ b/addons/auth_oauth_provider/res_users.py @@ -26,19 +26,26 @@ class res_users(osv.osv): _inherit = 'res.users' _columns = { + # TODO: partial implementation supporting only one client_id for the moment. 'last_oauth_token': fields.char('Last OAuth Token', readonly=True, invisible=True), + 'last_oauth_token_scope': fields.char('Last OAuth Token Scope', readonly=True, invisible=True), } def auth_oauth_provider_get_token(self, cr, uid, client_id="", scope="", context=None): chars = string.ascii_uppercase + string.ascii_lowercase + string.digits token = ''.join(random.choice(chars) for x in range(random.randrange(16, 24))) - self.write(cr, uid, [uid], { "last_oauth_token": token }, context=context) + self.write(cr, uid, [uid], { + "last_oauth_token": token, + "last_oauth_token_scope": scope, + }, context=context) return token def auth_oauth_provider_tokeninfo(self, cr, uid, access_token="", context=None): - if access_token == self.browse(cr, uid, [uid], context=context).access_token: + user = self.browse(cr, uid, [uid], context=context) + if access_token == user.last_oauth_token: return { "user_id": uid, + "scope": user.last_oauth_token_scope, #"audience": "8819981768.apps.googleusercontent.com", #"scope": "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email", #"expires_in": 436 diff --git a/addons/auth_oauth_provider/static/src/js/oauth_provider.js b/addons/auth_oauth_provider/static/src/js/oauth_provider.js index 593c013d21a..eb2c1982d31 100644 --- a/addons/auth_oauth_provider/static/src/js/oauth_provider.js +++ b/addons/auth_oauth_provider/static/src/js/oauth_provider.js @@ -16,6 +16,10 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ if (!params.redirect_uri) { this.error(_t("No 'redirect_uri' parameter given")); } + // params.client_id + // TODO: check if client_id application is authorized to use the service, and get it's name + // that should be displayed in the approval confirmation dialog. + // params.approval_prompt TODO if (!this._error) { instance.session.rpc('/oauth2/get_token', { |
