MoinMoin1.9からsuperuserだけが新規ユーザ作成できるようにする設定が楽になった。
1.8では、ユーザ作成を全面禁止したインスタンスを公開用とし、別途ユーザ作成用の非公開インスタンスを立てる必要があった。
下記のページに基本的な手順が載っているが、日本語資料があまり見つからなかったのでメモしておく。
http://moinmo.in/FeatureRequests/DisableUserCreation#Solution_for_1.9
1. myauth.pyを作成。
上記ページのコードをプチ修正。
ログイン画面で「もしくはパスワードをお忘れですか?」と表示できるようにするため、メッセージを「Forgot your password?」に修正。そのままだとドイツ語で表示される。
# pwd /usr/lib/python2.6/site-packages/MoinMoin/auth # vi myauth.py
# -*- coding: iso-8859-1 -*- from MoinMoin import log logging = log.getLogger(__name__) from MoinMoin.auth import BaseAuth, GivenAuth, MoinAuth from MoinMoin import user, wikiutil class MyAuth(MoinAuth): """ handle login from moin login form """ def login_hint(self, request): _ = request.getText #userprefslink = request.page.url(request, querystr={'action': 'newaccount'}) sendmypasswordlink = request.page.url(request, querystr={'action': 'recoverpass'}) return _('<a href="%(sendmypasswordlink)s">Forgot your password?</a>') % { 'sendmypasswordlink': sendmypasswordlink}
2. newaccount.pyをplugin/actionにダウンロード。
下記URLからダウンロードして、インスタンスディレクトリ/data/plugin/actionに配置。
こちらは特に修正不要。
http://moinmo.in/FeatureRequests/DisableUserCreation?action=AttachFile&do=view&target=newaccount.py
3. wikiconfig.py編集
インスタンスディレクトリ/wikiconfig.pyのSecurity関連を編集。
# Security ---------------------------------------------------------- # This is checked by some rather critical and potentially harmful actions, # like despam or PackageInstaller action: # superuserのユーザ名 superuser = [u"XXXX", ] # IMPORTANT: grant yourself admin rights! replace YourName with # your user name. See HelpOnAccessControlLists for more help. # All acl_rights_xxx options must use unicode [Unicode] # ページ閲覧はだれでもできるが、編集はログインが必要 # ACL(Access Control List)を編集できるようにadmin権限もあわせて付与 acl_rights_default = u'All:read' acl_rights_before = u"Known:read,write,delete,revert,admin" # The default (ENABLED) password_checker will keep users from choosing too # short or too easy passwords. If you don't like this and your site has # rather low security requirements, feel free to DISABLE the checker by: #password_checker = None # None means "don't do any password strength checks" # ** allow lazy password # 動作確認のため厳格なパスワードはなくてもよしとする password_checker = None # Link spam protection for public wikis (Uncomment to enable) # Needs a reliable internet connection. #from MoinMoin.security.antispam import SecurityPolicy # 参考:1.8用の設定(新規ユーザ作成を全面禁止) # actions_excluded = multiconfig.DefaultConfig.actions_excluded + ['newaccount'] # 1.9用の設定 # superuserのみに新規ユーザ作成許可するため # authモジュールを差し替える from MoinMoin.auth.myauth import MyAuth auth = [MyAuth()]
4. MoinMoinを再起動
5. 動作確認
新ユーザ作成アクションを適当なページに追加する。
superユーザでログインしているときにnewaccountリンクをクリックすると新規ユーザ作成画面になるが、一般ユーザや非ログイン状態では実行権限がない旨表示される。
<<Action(newaccount)>>