Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to parse NoAuthMiddlewareBase and NoAuthMiddleware

Shulou Source: shulou.com Published: 2022-05-31 16:29:08 10月18日 Update

In this issue, the editor will bring you about how to analyze NoAuthMiddlewareBase and NoAuthMiddleware. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

NoAuthMiddlewareBase parses class NoAuthMiddlewareBase (base_wsgi.Middleware): "if no corresponding request token is specified in the request header, a forged token is returned." Def base_call (self, req, project_id_in_path, always_admin=True): if'X AuthmurToken' not in req.headers: user_id = req.headers.get ('X Authllik user, 'admin') # sets the default user ID project_id = req.headers.get (' Xmuri AuthlieProjectId') 'admin') # set the default project IDif project_id_in_path: os_url =' / '.join ([req.url.rstrip (' /'), project_id]) else: os_url = req.url.rstrip ('/') res = webob.Response () # NOTE (vish): This is expecting and returning Auth Whereas # keystone uses 2.0 auth. We should probably allow # 2.0 auth here as well. Res.headers ['XmurkoToken'] ='% slug% s'% (user_id, project_id) # forged token res.headers ['XMaiServerManagementMublyUrl'] = os_url # set url res.content_type =' text/plain' # set content-type res.status = '204' return res token = req.headers [' XmurmurAuthToken'] user_id _ sep, project_id = token.partition (':') project_id = project_id or user_id remote_address = getattr (req, 'remote_address',' 127.0.0.1') if CONF.api.use_forwarded_for: remote_address = req.headers.get Remote_address) is_admin= always_admin or (user_id = = 'admin') ctx = context.RequestContext (user_id, project_id, is_admin=is_admin) Remote_address=remote_address) # encapsulates the request context req.environ ['nova.context'] = ctxreturn self.applicationNoAuthMiddleware parsing class NoAuthMiddleware (NoAuthMiddlewareBase): # inherits the parent class @ webob.dec.wsgify (RequestClass=wsgi.Request) def _ _ call__ (self, req): return self.base_call (req, True) Always_admin=False) # call the specific implementation of the parent class above is the editor to share with you how to parse NoAuthMiddlewareBase and NoAuthMiddleware If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Tokens content analysis up and down context professional small and medium rich in content that is articles more users knowledge articles industry perspective information channels projects channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info Docker Linux MariaDB