密码保护ExpressionEngine模板组

Dou*_*oug 10 expressionengine

我正在建立一个网站,工作人员将拥有自己的网站部分:example.com/jones,example.com/smith等.jones和smith是内部具有相同模板的模板组(使用Stash和Low Variables保持这一切都干了).一些用户对隐私有不同的需求.一方面,他们的部分将是公开的.另一方面,一些用户需要管理谁可以访问他们的内容(使用Solspace朋友).

然而,在这个范围的中间是一些人只想防止任何随机的人看到他们的内容.我不想使用成员/成员组来管理它.我不希望访问者需要注册才能看到内容.共享会员帐户是一个选项,但我们由于其他问题而排除了这一点(如果重置密码,评论留在同一帐户下,等等.

我们想要的是密码保护模板组.工作人员可以让人们知道在哪里看到他们的页面,让用户知道密码是什么.这在服务器级别都是可能的,但是可以允许用户直接管理密码吗?我们可以做的任何事情,以尽量减少我们需要多少管理这个更好.自定义字段和添加项允许这种安全性?我没有在Devot-ee上看到任何内容,论坛上的方法也没有这样做.有点过分,但我想问.

Ale*_*ick 11

既然你说你不想被绑在实际的会员账户上,并且可以使用自定义字段来存储可编辑的密码......

我刚刚做了类似的事情,使用自定义字段保护了一组条目.它类似于" 密码保护内容变得简单 "一文中概述的方法.但是我没有在模板中使用PHP,而是使用了Mo'变量.而不是使用url_title我使用了自定义字段(下面称为client_password).

此外,我使用Session Variables插件检查用户是否已在后续页面加载时"登录",从而阻止他们不得不一次又一次地输入密码.

{!-- PASSWORD REQUIRED --}
{if client_password != ""}

    {!-- if passed show content and set session --}
    {if post:password == client_password}

        {!-- protected content here --}
        {!-- set session --}
        {embed='embeds/_set_session' entry_id="{entry_id}"}

    {!-- if session is valid show content --}
    {if:elseif "{exp:session_variables:get name='logged_in'}" == "{entry_id}"}

        {!-- protected content here --}

    {!-- if failed show login --}   
    {if:elseif post:password != "" AND post:password != client_password}

        <div id="protected">
            <p>Incorrect password. Please try again.</p>
            <br>
            <form action="" method="post">
                <strong>Password</strong><br />
                <div>
                    <input name="password">
                </div>
                <input type="submit" class="submit" value="submit">
            </form>             
        </div>

    {!-- if first attempt show login and prompt --}
    {if:else}

        <div id="protected">
            <p>This page is password protected. Please provide the password.</p>
            <br>
            <form action="" method="post">
                <strong>Password</strong><br />
                <div>
                    <input name="password">
                </div>
                <input type="submit" class="submit" value="submit">
            </form>             
        </div>

    {/if}

{!-- NO PASSWORD REQUIRED --}
{if:else}

    {!-- protected content here --}

{/if}
Run Code Online (Sandbox Code Playgroud)


Dou*_*oug 5

我想用我正在使用的代码来更新这个以使htaccess和htpasswd工作以通过模板组保护.它可以像Alex一样使用,但是全有或全无的方法.它有自己的优点和缺点,但想分享它作为一种选择.

首先,我使用的是原生模板行为:example.com/group/template/url_title.我想密码保护一些模板组,但在EE的成员和成员组之外.即单个用户和密码.

我的htaccess文件看起来像这样(来自http://perishablepress.com/enable-file-or-directory-access-to-your-htaccess-password-protected-site/):

# We set some variables, matching URL's for which we do not wish to active
# the password protection
SetEnvIf Request_URI "^/privategroup.*$" private

# Setup the password protection
AuthName "Password Needed"
AuthGroupFile /dev/null
AuthType Basic
AuthUserFile /Users/user/Sites/example/.htpasswd
Require valid-user

# Add the exceptions for matched URL's
Order Deny,Allow
Deny from env=private
Satisfy any
Run Code Online (Sandbox Code Playgroud)

htpasswd文件应该在webroot之上,但是为了测试我把它留在webroot中.AuthUserFile行告诉Apache在哪里可以找到带有用户名和密码的文件.这必须......必须是绝对的道路.我使用亲戚并得到500错误.您需要使用终端或其他工具来制作此文件.http://developer.apple.com/library/Mac/#documentation/Darwin/Reference/ManPages/man1/htpasswd.1.html

结果是该目录需要用户名和密码.现在它将接受我的htpasswd文件中的任何有效用户.但是,我可以通过指定特定用户(需要用户john tim lisa)或组来更改它.

你有它.在不使用任何本机EE功能的情况下,让人们脱离特定模板组.