LoginSignup
5
2

More than 1 year has passed since last update.

ログイン実装について、Devise/Warden/Rack の関係を一言で

Last updated at Posted at 2021-09-09

Rails のログイン実装でお馴染みの Devise について調べたため、メモを残します。引用元を合わせて記します。

Devise とは?

・Rails に認証を実装するためのソリューションのこと
Warden がベースになっている

Devise is a flexible authentication solution for Rails based on Warden.
−− Github

Warden とは?

Rack 内で、認証するメカニズムを与えてくれるもの

Warden provides a mechanism for authentication in Rack based Ruby applications.
−− Github

つまり、
1. Rack 内で、
2. Warden というものが認証するメカニズムを提供し、
3. Deviseがそのメカニズムを Rails に実装してくれる。
ということですね!

Rack とは?

・Ruby で、WEB開発をするためのインターフェースを与えてくれるもの
・HTTPリクエストとHTTPレスポンスを束ねて、APIとし、シングルメソッドコールにしてくれるもの(要は、Rack のおかげで API が打てるということですね)

Rack provides a minimal, modular, and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.
−− Rails guides

ちなみに、この文章での distills the API(一般的に distills は「蒸留する」)の意味が最初は謎でした。(APIを蒸留するとは…?)
そこで、オックスフォード英英辞典を参考にしました。↓↓

distil sth (from/into sth)
to get the essential meaning or ideas from thoughts, information or experiences
-- Oxford Academic English

なるほど、distills には「インフォメーションからエッセンシャルなものを取り出す」というような意味合いがあるみたいですね。参考にしてください。

まとめ

Rack 内で、Warden による認証メカニズムを、 Devise が Rails に実装してくれる。

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2