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 ...@@ -33,7 +33,7 @@ from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PluggableAuthService.interfaces import plugins from Products.PluggableAuthService.interfaces import plugins
from Products.PluggableAuthService.utils import classImplements from Products.PluggableAuthService.utils import classImplements
from Products.PluggableAuthService.plugins.BasePlugin import BasePlugin 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 Products.PluggableAuthService.PluggableAuthService import DumbHTTPExtractor
from AccessControl.SecurityManagement import getSecurityManager, \ from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager, newSecurityManager setSecurityManager, newSecurityManager
...@@ -96,15 +96,10 @@ class ERP5BearerExtractionPlugin(BasePlugin): ...@@ -96,15 +96,10 @@ class ERP5BearerExtractionPlugin(BasePlugin):
pass pass
if token is not None: if token is not None:
sm = getSecurityManager() with super_user():
if sm.getUser().getId() != SUPER_USER:
newSecurityManager(self, self.getUser(SUPER_USER))
try:
reference = self.Base_extractBearerTokenInformation(token) reference = self.Base_extractBearerTokenInformation(token)
if reference is not None: if reference is not None:
creds['external_login'] = reference creds['external_login'] = reference
finally:
setSecurityManager(sm)
if 'external_login' in creds: if 'external_login' in creds:
creds['remote_host'] = request.get('REMOTE_HOST', '') creds['remote_host'] = request.get('REMOTE_HOST', '')
try: 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