Rails: LoginEngine を用いての認証2006年09月30日 12時09分25秒

LoginEngineを使ってみるを参考に設定。なお、以下のものは個人的な作業記録と防備録。

定型的な下準備。


% rails login
...
      create  log/development.log
      create  log/test.log
% cd login

plugin というスクリプトがある。既に実行可能にされているので ruby の指定は必須ではない。また、プラグインは、vendor/plugins というディレクトリに配置されるようだ。

% ruby script/plugin
Unknown command:
Usage: plugin [OPTIONS] command
Rails plugin manager.
...
% ls vendor/plugins/
%

始めて discover をやるとソースの配付元の指定するのに大量のプロンプトが出るので yes で省略。


% yes | ruby script/plugin discover
...
http://www.nickm.org/svn/repos/rails/plugins/? [Y/n]
Add http://cubesix.net/rails/plugins/? [Y/n]
Add http://svn.rtra.in/public/plugins/? [Y/n]
Add http://svn.superruby.com/svn/plugins/? [Y/n]

login_engine のプラグインをインストール。依存関係も解決してくれるようだ。


% ruby script/plugin install login_engine
+ ./login_engine/CHANGELOG
+ ./login_engine/README
+ ./login_engine/app/controllers/user_controller.rb
...
+ ./engines/lib/engines.rb
+ ./engines/tasks/deprecated_engines.rake
+ ./engines/tasks/engines.rake
+ ./engines/test/action_view_extensions_test.rb
+ ./engines/test/ruby_extensions_test.rb
% ruby script/plugin install engines
already installed: engines (http://svn.rails-engines.org/plugins/engines/).  pass --force to reinstall
% ls vendor/plugins/
engines         login_engine

LoginEngine の設定。

config/environment.rb の末尾に以下のような行を追加します。

module LoginEngine
  config :salt, "my-salt"
  config :email_from, "webmaster@example.com"
  config :admin_email, "admin@example.com"
  config :app_name, "MyApp"
end

Engines.start :login

... その他の config パラメータの意味については vendor/plugin/login_engine/lib/login_engine.rb を見てください。
とあった。example.com のまま試しても問題ないのだろうか。一応、自分の物を使おうと思う。

Ruby on Rails は初めてで、普段は Ruby を使う機会もない。あちこちの説明を読みながら、メモを取りながら実験するので時間が掛かる。十五分で blog を完成とはいかないようだ。

前回次回