Python WSGI作为AuthFormProvider

Python WSGI作为AuthFormProvider,python,django,mod-wsgi,apache2.4,Python,Django,Mod Wsgi,Apache2.4,是否可以在Apache2.4中将“wsgi”用作AuthFormProvider 作为第一次尝试,我编辑了找到的示例。 配置现在看起来像这样,但不起作用: <Location "/test"> AuthType Form AuthFormProvider wsgi AuthName "test" AuthFormLoginRequiredLocation /login.html WSGIAuthUserScript /path/to/djang

是否可以在Apache2.4中将“wsgi”用作AuthFormProvider

作为第一次尝试,我编辑了找到的示例。 配置现在看起来像这样,但不起作用:

<Location "/test">
    AuthType Form
    AuthFormProvider wsgi
    AuthName "test"
    AuthFormLoginRequiredLocation /login.html
    WSGIAuthUserScript /path/to/django/wsgi.py
    WSGIAuthGroupScript /path/to/django/wsgi.py
    Require Group test
    Require valid-user
    Session On
    SessionCookieName xyz path/
    SessionCrypotPassphrase 123456789
</Location>

AuthType表单
AuthFormProvider wsgi
AuthName“测试”
AuthFormLoginRequiredLocation/login.html
WSGIAuthUserScript/path/to/django/wsgi.py
WSGIAuthGroupScript/path/to/django/wsgi.py
要求分组测试
需要有效用户
关于
SessionCookieName xyz路径/
会话密码短语123456789

首先,您必须使用mod_wsgi 4.3.0才能使WSGIAuthGroupScript与Apache 2.4配合使用。Apache2.4的内部结构从2.2发生了变化,这是最近才实现的。这个问题只在mod_wsgi的最新版本中得到了解决。如果您在Linux发行版上停留在旧的mod_wsgi版本上,并且拒绝更新,那么您就不走运了

其次,您必须使用:

Require wsgi-group test
在Apache 2.4下,您不能使用:

Require group test
如果使用WSGI身份验证提供程序

这也是因为Apache 2.4中的更改

总的来说,我建议你将你的问题发布到mod_wsgi邮件列表中,我会在那里处理。在这里,StackOverflow是一个可怕的地方,我可以很容易地看到它变成了任何一种冗长的来回讨论


为了它的价值,我一直热衷于研究mod_会话与mod_wsgi的交互,但如果你跳转到mod_wsgi邮件列表,我肯定没有机会这么有兴趣来帮助探索这个问题。

解决方案是,我必须更新到mod_wsgi 4.3.0,并按照Graham Dumpleton在回答(或)中提到的那样更改配置

除了更新之外,我删除了AuthFormLoginRequiredLocation指令,并添加了ErrorDocument指令

工作配置现在如下所示:

<Location "/test">
    AuthType Form
    AuthFormProvider wsgi
    AuthName "test"
    ErrorDocument 401 /login.html
    WSGIAuthUserScript /path/to/django/wsgi.py
    WSGIAuthGroupScript /path/to/django/wsgi.py
    <RequireAll>
        Require wsgi-group test
        Require valid-user
    </RequireAll>
    Session On
    SessionCookieName xyz path/
    SessionCrypotPassphrase 123456789
</Location>

AuthType表单
AuthFormProvider wsgi
AuthName“测试”
ErrorDocument 401/login.html
WSGIAuthUserScript/path/to/django/wsgi.py
WSGIAuthGroupScript/path/to/django/wsgi.py
需要wsgi组测试
需要有效用户
关于
SessionCookieName xyz路径/
会话密码短语123456789

非常感谢。我已经阅读了你的解决方案[在这里|并更改了配置,但它没有完全完成使用mod|u auth|u表单运行整个登录过程的工作。对于我的网站,我必须将“AuthFormLoginRequiredLocation/login.html”更改为“ErrorDocument 401/login.html”。Apache网站上的示例不太有用,也不容易被误解。正如我之前所说,在mod_wsgi 4.3.0中,您必须使用“Require wsgi group test”而不是“Require group test”。您所拥有的不会触发mod_wsgi auth provider,而是尝试应用一个与不同Apache模块相关的程序。