More Related Content
Similar to Herokuで作るdevise認証サイト (20)
More from Fukui Osamu (11)
Herokuで作るdevise認証サイト
- 1. Herokuで作るDevise
認証サイト
2012.5.29 【第2回】渋谷Railsだったり勉強会
@iR3 iRubySystems 福井修
- 10. 重要な指摘!!!
• 単なる OAuth 2.0 を認証に使うと、車が
通れるほどのどでかいセキュリティー・
ホールができる
• http://www.sakimura.org/
2012/02/1487/
- 12. • OAuth 2.0 の Client は、そのClient (サ
イト)にログインしたすべての人になりす
まして、任意の他のOAuth 対応サイトに
ログインできるのです。
• これは、OAuth の問題ではありません。
- 13. • OAuth は Authorization Delegation
Protocol = 認可をデリゲーションするた
めのプロトコルであって、ユーザ認証の
ためのプロトコルではないからです。
はっきり言って、楽ちんだからといっ
て、それを単体で認証の代わりに使って
いる方が悪い。
と崎村夏彦 @_natさんが
御指摘されています!!
- 16. Deviseとは?
Devise は Warden をベースにした Rails のための
柔軟で高機能な認証ライブラリ
Rackベース
Rails エンジンに基づいた完全な MVC ソリューション
必要な部分だけ使えるモジュラー構造
2012.5.29現在 devise2.1 で12モジュール構成
- 18. 認証ライブラリの変遷
CGI時代 Rails1 Rails2 Rails3
当初Clearance/
acts_as_authent restful_authent Authlogic
個別作り込み
icated ication ,warden
徐々にdevise
- 20. deviseインストール
Gemfileに指定を追加
gem 'devise'
$ bundle install
deviseの環境準備
$ rails generate devise:install
この結果に手順が出力されます。
以下 @fukajunさんの次のサイトの記事がおすすめです。
http://kitbc.s41.xrea.com/main/?use_devise
- 21. i18n日本語対応
i18n で日本語辞書を対応づけて翻訳
Gemfile.rockでi18nのgemを確認。defaultで入る。
activesupport (3.2.3)
i18n (~> 0.6)
locale設定を日本語にする。
config.application.rb
# config.i18n.default_locale = :de
config.i18n.default_locale = :ja
- 23. i18n日本語対応
i18n で日本語辞書を対応づけて翻訳
ja.yaml
http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale
より入手。 deviseに限らず日付時刻表記など一般的なもの
ja:
date:
formats:
default: "%Y/%m/%d"
short: "%m/%d"
long: "%Y年%m月%d日(%a)"
day_names:
- '日曜日'
:
- 25. i18n日本語化
helpers.ja.yml ja:
helpers:
submit:
form文の文言 create: "登録する"
update: "更新する"
submit: "保存する"
label:
user:
email: "メールアドレス"
password: "パスワード"
- 26. devise日本語対応
ja:
devise.ja.yml "Sign in": サインイン
"Registration": ユーザ登録
"Sign up": ユーザ登録する
"Forgot your password?": パスワード忘れはこちら
"Send me reset password instructions": パスワード再発行
"Resend confirmation instructions": パスワード再発行
errors:
エラーメッセージ messages:
not_found: "は見つかりませんでした。"
# not_found: "not found"
already_confirmed: "は既に登録済みです。"
# already_confirmed: "was already confirmed"
not_locked: "はサインイン可能です。"
# not_locked: "was not locked"
devise:
failure:
unauthenticated: 'サインインしてください。'
# unauthenticated: 'You need to sign in or sign up before
continuing.'
unconfirmed: '本登録を行ってください。'
- 30. Herokuとは?
PaaS : Platform As A Service のひとつ
Railsが動作するので、かつては知る人ぞ知る存在であった。
2010年末Heroku社はSalesForceに買収され経営基盤が盤石に。
2011年7月Matz(Rubyの父まつもとゆきひろ氏)がチーフアー
キテクトに就任。
2011年12月RubyパッチモンスターなかださんもJoin
2012年2月 エンタープライズRailsを頑張った@ayuminもJoin
2012年4月 Ruby1.9 VM(旧YARV)の東大ささださんもJoin
今やRubyistにとって何か特別の存在に。
- 36. ローカルGitリポジトリ
$rails new hoge Railsプロジェクト作成
$cd hoge プロジェクトホームへ
$git init
$git add . リポジトリ初期化
$git commit -m ‘hoge start’ 変更分をindex登録
ローカルリポジトリcommit
Editor's Notes
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n