【问题标题】:WSGI as AuthFormProviderWSGI 作为 AuthFormProvider
【发布时间】:2014-11-13 22:36:04
【问题描述】:

是否可以在 Apache2.4 中使用 'wsgi' 作为 AuthFormProvider?

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

<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>

【问题讨论】:

    标签: python django mod-wsgi apache2.4


    【解决方案1】:

    首先,您必须使用 mod_wsgi 4.3.0 才能使 WSGIAuthGroupScript 与 Apache 2.4 一起使用。 Apache 2.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_session 与 mod_wsgi 的交互,但如果您跳转到 mod_wsgi 邮件列表,我从来没有机会帮助探索这个问题。

    【讨论】:

    • 非常感谢。我已经阅读了您的解决方案 [这里|github.com/GrahamDumpleton/mod_wsgi/issues/25] 并更改了配置,但它并没有完全完成使用 mod_auth_form 运行整个登录过程的工作。对于我的网站,我必须将“AuthFormLoginRequiredLocation /login.html”更改为“ErrorDocument 401 /login.html”。 Apache 网站上的示例不是很有帮助,也很容易被误解。
    【解决方案2】:

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

    除了更新之外,我还删除了指令 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>
    

    【讨论】:

    • 正如我之前所说,在 mod_wsgi 4.3.0 中,您必须使用“需要 wsgi-group 测试”而不是“需要组测试”。您所拥有的不会触发 mod_wsgi 身份验证提供程序,而是尝试应用与不同 Apache 模块相关的一个。
    猜你喜欢
    • 2021-11-28
    • 2013-08-27
    • 2017-10-13
    • 1970-01-01
    • 2014-12-31
    • 2022-01-02
    • 2021-10-03
    • 2010-12-21
    • 2011-09-21
    相关资源
    最近更新 更多