Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to parse NoAuthMiddlewareBase and NoAuthMiddleware

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report