#author("2017-12-24T02:47:47+00:00","default:inoue.ko","inoue.ko")
*ユーザ認証と正規表現
User Authentication & Regular Expression
~
**はじめに
PukiWikiでは、ユーザ認証機能を利用することで、ページの閲覧制限、編集制限、検索制限をすることができます。pukiwiki.ini.php で以下の設定が必要です。
~
***アクセス制御で使用するユーザ名とパスワードを設定
/////////////////////////////////////////////////
// User definition
$auth_users = array(
// Username => password
'foo' => 'foo_passwd', // Cleartext
'bar' => '{x-php-md5}f53ae779077e987718cc285b14dfbe86', // PHP md5() 'bar_passwd'
'hoge' => '{SMD5}OzJo/boHwM4q5R+g7LCOx2xGMkFKRVEx', // LDAP SMD5 'hoge_passwd'
);
~
***認証方式(ページ名かページの内容か)
/////////////////////////////////////////////////
// Authentication method
$auth_method_type = 'pagename'; // By Page name ← ふつうはこちら
//$auth_method_type = 'contents'; // By Page contents
~
***閲覧認証の設定
/////////////////////////////////////////////////
// Read auth (0:Disable, 1:Enable)
$read_auth = 1; // ← ここを1
$read_auth_pages = array(
// Regex Username
'#HogeHoge#' => 'hoge',
'#(NETABARE|NetaBare)#' => 'foo,bar,hoge',
);
~
***編集認証の設定
/////////////////////////////////////////////////
// Edit auth (0:Disable, 1:Enable)
$edit_auth = 1; // ← ここを1
$edit_auth_pages = array(
// Regex Username
'#BarDiary#' => 'bar',
'#HogeHoge#' => 'hoge',
'#(NETABARE|NetaBare)#' => 'foo,bar,hoge',
);
~
***正規表現による制限方法の記述例
-全ページに制限をかける。
$edit_auth_pages = array(
'##' => 'hoge',
);
-ページ Apple に制限をかける。
$edit_auth_pages = array(
'#^Apple$#' => 'hoge',
);
-ページ Apple と Orange に制限をかける。
$edit_auth_pages = array(
'#(^Apple$|^Orange$)#' => 'hoge',
);
または
$edit_auth_pages = array(
'#^Apple$#' => 'hoge',
'#^Orange$#' => 'hoge',
);
-Comments/ で始まるページに制限をかける。
$edit_auth_pages = array(
'#^Comments/#' => 'hoge',
);
-/template で終わるページに制限をかける。
$edit_auth_pages = array(
'#/template$#' => 'hoge',
);
-Comments/ で始まるページ以外に制限をかける。
$edit_auth_pages = array(
'#^(?!^Comments/)#' => 'hoge',
);
-/template で終わるページ以外に制限をかける。
$edit_auth_pages = array(
'#^(?!^.*/template$)#' => 'hoge',
);
~
参考:[[PukiWiki/Install/ユーザ認証>https://pukiwiki.osdn.jp/?PukiWiki/Install/%E3%83%A6%E3%83%BC%E3%82%B6%E8%AA%8D%E8%A8%BC]]
~
~