Skip to content

Commit

Permalink
[FIX] auth_oauth_ip: Do not break inheritance in _auth_oauth_validate to
Browse files Browse the repository at this point in the history
call auth_oauth_check_client_id method
  • Loading branch information
FFernandez-PlanetaTIC committed Dec 13, 2018
1 parent 0f05702 commit 87ab678
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions auth_oauth_ip/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class res_users(models.Model):
_inherit = 'res.users'

def _auth_oauth_rpc(self, endpoint, access_token, local_host=None, local_port=None):
local_host = local_host or self.env.context.get('local_host')
local_port = local_port or self.env.context.get('local_port')
params = werkzeug.url_encode({'access_token': access_token})
host = None
try:
Expand All @@ -39,22 +41,13 @@ def _auth_oauth_rpc(self, endpoint, access_token, local_host=None, local_port=No
else:
url = endpoint + '?' + params
req = urllib.request.Request(url, headers={'host': host})
print(('url', url))

with urllib.request.urlopen(req) as response:
html = response.read()
return json.loads(html.decode("utf-8"))

@api.model
def _auth_oauth_validate(self, provider, access_token):
""" return the validation data corresponding to the access token """
p = self.env['auth.oauth.provider'].browse(provider)
validation = self._auth_oauth_rpc(
p.validation_endpoint, access_token, local_host=p.local_host, local_port=p.local_port)
if validation.get("error"):
raise Exception(validation['error'])
if p.data_endpoint:
data = self._auth_oauth_rpc(
p.data_endpoint, access_token, local_host=p.local_host, local_port=p.local_port)
validation.update(data)
return validation
self = self.with_context(local_host=p.local_host, local_port=p.local_port)
return super(res_users, self)._auth_oauth_validate(provider, access_token)

0 comments on commit 87ab678

Please sign in to comment.