Ruby onRails Advent Calendar 21日目の記事です。 DeviseとOmniauthを使って認証管理をしてみます。 Deviseとは何か Devise is a flexible authentication solution forRails based on Warden.It: Is Rack based; Is a complete MVC solution based onRails engines; Allows you to have multiple models signed in at the same time; Is based on a modularity concept: usejust what you really need. とGithubにあるように、 WardenをベースとしたRails向けフレキシブル オーセンテ

今作っているサービスが後々、OAuth、OpenIDあたりにも対応することになるかもしれないので、そのあたり柔軟に対応できそうなwardenを試してみました。 必要なgemはwardenとrails_wardenの2つ。 Userモデルは以下のような感じで。 次にgithubのページを参考にconfig/initializers/warden.rbを追加します。今回はパスワードで認証をしたいのでpasswordのstrategyを自分で追加します。(と言ってもほとんどサンプルと同じ) この後はUser.authenticateの中身をfindbyloginandpasswordとかで実装してもいいのですが、それだとパスワードが平文になってしまうのでrestful_authenticationのコードを少し拝借することにします。 includeいているものがrestful_authentic
DismissJoinGitHub todayGitHub is home to over 28 million developers working together to host and review code, manage projects, andbuild software together. Sign up Restful Authentication Generator This widely-used plugin provides a foundation for securely managing user authentication:Login /logout Secure password handling Account activation by validatingemail Account approval / disabling by
1リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く