Commit 0b2c77f0 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Vincent Pelletier

ERP5Security: simplify ERP5BearerExtractionPlugin.

parent 19a57e3b
......@@ -33,7 +33,7 @@ from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PluggableAuthService.interfaces import plugins
from Products.PluggableAuthService.utils import classImplements
from Products.PluggableAuthService.plugins.BasePlugin import BasePlugin
from Products.ERP5Security.ERP5UserManager import SUPER_USER
from Products.ERP5Type.UnrestrictedMethod import super_user
from Products.PluggableAuthService.PluggableAuthService import DumbHTTPExtractor
from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager, newSecurityManager
......@@ -96,15 +96,10 @@ class ERP5BearerExtractionPlugin(BasePlugin):
pass
if token is not None:
sm = getSecurityManager()
if sm.getUser().getId() != SUPER_USER:
newSecurityManager(self, self.getUser(SUPER_USER))
try:
with super_user():
reference = self.Base_extractBearerTokenInformation(token)
if reference is not None:
creds['external_login'] = reference
finally:
setSecurityManager(sm)
if 'external_login' in creds:
creds['remote_host'] = request.get('REMOTE_HOST', '')
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment