codeq / passwordprotectedcontent
密码保护任何文档和内容节点类型
v1.4.0
2023-02-06 19:36 UTC
Requires
- carbon/notification: ^1.0 || ^2.0 || dev-master
- neos/neos: ~3.2 || ~4.0 || ~5.0 || ~7.0 || ~8.0 || dev-master
README
为Neos CMS密码保护内容
此包允许编辑器对包含混合功能的任何文档和内容节点类型进行密码保护。
注意: 此功能不应用于需要强保护的敏感内容。我们将在内容存储库中存储未加密的密码,以便多个编辑员可以查看和更改密码。密码不是个性化的,因此可以轻易共享。此外,此包中也没有暴力破解保护。
限制
- 没有暴力破解保护
- 没有存储允许页面的会话
安装
CodeQ.HtmlWidget 通过 Packagist 提供。在 composer.json 的 require 部分,添加 "codeq/passwordprotectedcontent" : "~1.0"
,或运行
composer require codeq/passwordprotectedcontent
我们使用语义版本控制,每次重大变更都会增加主版本号。
使用方法
- 将混合
'CodeQ.PasswordProtectedContent:Mixin.Password'
添加到任何节点类型,以允许编辑器配置密码。 - 添加以下过程函数以保护内容
@process.protect = CodeQ.PasswordProtectedContent:Helper.ProtectContent
。过程函数不会自动添加,因为您可能希望渲染页面的页眉和页脚。现在您可以具体定义哪些内容应渲染,哪些不应渲染。 - 您需要配置 Fusion 对象,以便根据帖子参数动态缓存,如下所示
@cache { mode = 'dynamic' entryIdentifier { node = ${node} } context { 1 = 'node' 2 = 'documentNode' 3 = 'site' } // cache the initial request ot see the form and don't cache the password-check result entryDiscriminator = ${request.httpRequest.methodSafe ? 'static' : false} }
与内容集合的使用
要替换内容集合以使用密码保护表单,您需要从文档节点而不是内容集合节点获取密码,您可能也不想使用单独的缓存。因此,将上述 @cache 应用到文档节点渲染,并按如下方式渲染内容集合
main = Neos.Neos:ContentCollection {
nodePath = 'main'
@process.protect = CodeQ.PasswordProtectedContent:Helper.ProtectContent {
configuredPassword = ${q(documentNode).property('passwordProtectedContentPassword')}
}
@cache {
mode = 'embed'
}
}
替换默认表单渲染
您也可以通过覆盖原型来替换表单渲染
prototype(CodeQ.PasswordProtectedContent:Component.PasswordForm) {
renderer = 'YOUR CODE'
}
许可协议
在 MIT 许可下发布,请参阅 LICENSE
贡献
我们乐意接受贡献。请发送给我们 pull requests。
本包的开发和公共发布得到了 Code Q Web Factory 的慷慨赞助 Code Q Web Factory。