[IMP] Wip oauth
bzr revid: fme@openerp.com-20120924084433-95rtadp5omhkc6x3
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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', {
|
||||
|
||||
Reference in New Issue
Block a user