简体   繁体   English

如果我在mod_python上有一些网页,在mod_wsgi上有一些网页,则保持用户身份验证

[英]maintaining user authentication if i have some web pages on mod_python and some on mod_wsgi

I have a web application written in raw python and hosted on apache using mod_python. 我有一个用原始python编写的Web应用程序,并使用mod_python托管在apache上。 I am building another web application which is django based and will be hosted on same server using mod_wsgi. 我正在构建另一个基于Django的Web应用程序,它将使用mod_wsgi托管在同一服务器上。

Now, the scenerio is such that user will login from the web page which is using mod_python and a link will send him to my application which will be using mod_wsgi. 现在,scenario可以使用户从使用mod_python的网页登录,并将链接发送到使用mod_wsgi的应用程序。 My question is how can I maintain session? 我的问题是如何保持会议状态? I need the same authentication to work for my application. 我需要相同的身份验证才能为我的应用程序工作。 Thanks in advance. 提前致谢。

If you're using django with mod_wsgi and a raw python page which only serve a link to django application, you don't need to maintain session on both page. 如果您在django中使用mod_wsgi和一个仅提供指向django应用程序链接的原始python页面,则无需在两个页面上都保持会话。 When user click on first link and reach the django application, just check session there. 当用户单击第一个链接并到达django应用程序时,只需在此处检查会话即可。

Django have session_db which use memcache. Django有使用memcache的session_db。 More information can be found here: Django Sessions 可以在这里找到更多信息: Django Sessions

SSO across web applications is poorly supported. 跨Web应用程序的SSO支持不佳。 One thing you can look at is: 您可以看的一件事是:

http://www.openfusion.com.au/labs/mod_auth_tkt/ http://www.openfusion.com.au/labs/mod_auth_tkt/

What you can do is really going to depend though on what authentication database you are currently using in the mod_python application and how you are remembering that someone is logged in. If you can provide that information, may be able to suggest other things. 实际上,您可以做的事情取决于在mod_python应用程序中当前使用的身份验证数据库以及您如何记住某人已登录。如果您可以提供该信息,则可能会提出其他建议。

Conceptually: store a cookie using your raw python web page that you process in a "welcome" view or custom middleware class in Django, and insert them into the sessions db. 从概念上讲:使用您在Django的“欢迎”视图或自定义中间件类中处理的原始python Web页面存储cookie,然后将其插入会话数据库中。 This is basically what hungnv suggests. 基本上这就是Hangnv的建议。

The most ridiculous way to do this would be to figure out how Django deals with sessions and session cookies, insert the correct row into Django's session database from your raw python app, and then custom-set the session cookie using Django's auth functions. 最可笑的方法是弄清楚Django如何处理会话和会话cookie,从原始python应用程序将正确的行插入Django的会话数据库,然后使用Django的auth函数自定义设置会话cookie。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM