bueltge/authenticator

此插件允许您仅允许登录用户访问您的WordPress网站。

安装次数: 4

依赖项: 0

建议者: 0

安全: 0

星标: 24

关注者: 8

分支: 7

开放问题: 4

类型:wordpress-plugin

1.3.1 2022-11-23 19:03 UTC

This package is auto-updated.

Last update: 2024-08-23 22:56:38 UTC


README

此插件允许您仅允许登录用户访问您的WordPress网站。

描述

此插件允许您仅允许登录用户访问您的WordPress网站。换句话说,要查看您的网站,他们必须创建或拥有您的网站账户并登录。无需配置,只需激活即可 - 就这么简单。

Inpsyde 制作 · 我们热爱WordPress

安装

要求

  • WordPress版本5.0及以上。
  • PHP 5.6及以上。
  • 单站或多站安装。

在PHP-CGI设置中

  • mod_setenvifmod_rewrite(如果您想为源使用HTTP身份验证)。

安装

  1. 解压缩下载的包。
  2. 将文件夹中的文件上传到 /wp-content/plugins/ 目录。
  3. 通过WordPress中的“插件”菜单激活插件。

或者通过WordPress后台使用安装程序。

在PHP-CGI设置中

如果您想使用HTTP身份验证为源(从1.1.0版起作为可选功能提供),您必须更新您的 .htaccess 文件。如果 mod_setenvif 可用,请将以下行添加到您的 .htaccess

SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1

否则您需要启用 mod_rewrite。在这种情况下,您必须将以下行添加到您的 .htaccess

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

在典型的WordPress .htaccess 文件中,一切看起来都像这样

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule . /index.php [L]
</IfModule>

在多站安装中

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule . index.php [L]
# END WordPress

设置

您可以在“设置”→“阅读”中更改Authenticator的设置。这些设置与您的博客源的行为有关。它们可以通过HTTP身份验证(不是所有源阅读器都支持此功能)或通过添加到您的源URL作为参数的身份验证令牌来保护。第三个选项是保持一切不变。因此,如果用户未登录,则源URL将重定向到登录页面(不发送身份验证cookie)。

如果您使用令牌身份验证,您可以通过设置此选项在用户的个人资料设置页面上向博客用户显示令牌。

HTTP身份验证

用户可以使用他们的用户名和密码访问源。

令牌身份验证

选择此选项时,插件将自动生成令牌。将此令牌复制并分享给应该有权访问您的源的人。如果您的令牌是 ef05aa961a0c10dce006284213727730,则源URL看起来像这样

# Main feed
https://example.com/feed/?ef05aa961a0c10dce006284213727730

# Main comment feed
https://example.com/comments/feed/?ef05aa961a0c10dce006284213727730

# Without permalinks
https://example.com/?feed=rss2&ef05aa961a0c10dce006284213727730

屏幕截图

  1. 在“设置”→“阅读”中的Authenticator设置选项。 Screenshot of setting options at Settings → Reading

  2. 在用户的个人资料设置页面上显示的源令牌。 Screenshot of Auth token for feeds is displayed on the users profile settings page

API

过滤器

  • authenticator_get_options 允许您访问当前的认证令牌

    $authenticator_options = apply_filters( 'authenticator_get_options', array() );
  • authenticator_bypass 允许您完全跳过身份验证。此时不需要进行身份验证。

    add_filter( 'authenticator_bypass', '__return_true' );
  • authenticator_bypass_feed_auth 允许您向所有人开放订阅源。此时不需要进行身份验证。

    add_filter( 'authenticator_bypass_feed_auth', '__return_true' );
  • authenticator_exclude_pagenows 向其传递一个包含 $GLOBALS[ 'pagenow' ] 值的数组,以排除多个 WordPress 页面重定向到登录页面。

  • authenticator_exclude_ajax_actions 不需要身份验证的 AJAX 操作(独立于 _nopriv),对所有人开放。

  • authenticator_exclude_posts 应保持公开的帖子标题列表,例如以下示例代码以公开“联系”页面。

    add_action( 'plugins_loaded', function() {
        add_filter( 'authenticator_exclude_posts', function( $titles ) {
            $titles[] = 'Contact'; // here goes the post-title of the post/page you want to exclude
            return $titles;
        } );
    } );

其他说明

错误、技术提示或贡献

请在我提供的 GitHub 仓库 上提供反馈、贡献并报告技术错误。

作者、贡献者

贡献者统计

许可协议

好消息,此插件对所有人免费!由于它是在 GPL 许可下发布的,您可以在个人或商业博客上免费使用它。

翻译

此插件包含各种翻译,有关激活翻译的更多信息,请参阅 WordPress Codex。如果您想帮助将插件翻译成您的语言,请查看 wordpress.org 页面,该页面提供了一个有用的管理功能来贡献翻译。

变更日志

查看 提交 或阅读简短的 版本