Class: Fizzy::CookieAuth
- Inherits:
-
Object
- Object
- Fizzy::CookieAuth
- Includes:
- AuthStrategy
- Defined in:
- lib/fizzy/cookie_auth.rb
Overview
Cookie-based authentication strategy. Sets the Cookie header with the session token for session-based auth (mobile/web clients).
Instance Method Summary collapse
- #authenticate(headers) ⇒ Object
-
#initialize(session_token, cookie_name: "session_token") ⇒ CookieAuth
constructor
A new instance of CookieAuth.
Constructor Details
#initialize(session_token, cookie_name: "session_token") ⇒ CookieAuth
Returns a new instance of CookieAuth.
16 17 18 19 20 21 |
# File 'lib/fizzy/cookie_auth.rb', line 16 def initialize(session_token, cookie_name: "session_token") raise ArgumentError, "session_token cannot be nil or empty" if session_token.nil? || session_token.empty? @session_token = session_token @cookie_name = end |
Instance Method Details
#authenticate(headers) ⇒ Object
23 24 25 |
# File 'lib/fizzy/cookie_auth.rb', line 23 def authenticate(headers) headers["Cookie"] = "#{@cookie_name}=#{@session_token}" end |