summaryrefslogtreecommitdiff
path: root/addons/auth_oauth
diff options
context:
space:
mode:
authorOlivier Dony <odo@odoo.com>2020-08-14 18:06:50 +0000
committerOlivier Dony <odo@odoo.com>2020-08-14 23:06:25 +0000
commit7cf64c2173c7bd30570617802b9658c5b3006bcc (patch)
treec91677bc8285c8a9390f148cca820b365f0598a8 /addons/auth_oauth
parenta9a65097132b53813991c9ce61c878ab3f302f53 (diff)
[IMP] auth*: adapt auth_* modules for totp
Prevent non-interactive RPC access when TOTP is enabled, also via external auth services.
Diffstat (limited to 'addons/auth_oauth')
-rw-r--r--addons/auth_oauth/models/res_users.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/addons/auth_oauth/models/res_users.py b/addons/auth_oauth/models/res_users.py
index 2ee46b6b38c..02a2bd97af8 100644
--- a/addons/auth_oauth/models/res_users.py
+++ b/addons/auth_oauth/models/res_users.py
@@ -113,9 +113,12 @@ class ResUsers(models.Model):
try:
return super(ResUsers, self)._check_credentials(password, env)
except AccessDenied:
- res = self.sudo().search([('id', '=', self.env.uid), ('oauth_access_token', '=', password)])
- if not res:
- raise
+ passwd_allowed = env['interactive'] or not self.env.user._rpc_api_keys_only()
+ if passwd_allowed and self.env.user.active:
+ res = self.sudo().search([('id', '=', self.env.uid), ('oauth_access_token', '=', password)])
+ if res:
+ return
+ raise
def _get_session_token_fields(self):
return super(ResUsers, self)._get_session_token_fields() | {'oauth_access_token'}