Module: LlamaBotRails::AgentAuth
- Extended by:
- ActiveSupport::Concern
- Included in:
- AgentController
- Defined in:
- lib/llama_bot_rails/agent_auth.rb,
lib/llama_bot_rails/agent_auth_2.rb
Constant Summary collapse
- AUTH_SCHEME =
"LlamaBot"
Instance Method Summary collapse
- #llama_bot_request? ⇒ Boolean
-
#should_check_agent_auth? ⇒ Boolean
-------------------------------------------------------------------- Public helper: true if the request carries a valid agent token --------------------------------------------------------------------.
Instance Method Details
#llama_bot_request? ⇒ Boolean
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/llama_bot_rails/agent_auth.rb', line 68 def llama_bot_request? return false unless request&.headers scheme, token = request.headers["Authorization"]&.split(" ", 2) Rails.logger.debug("[LlamaBot] auth header = #{scheme.inspect} #{token&.slice(0,8)}…") return false unless scheme == AUTH_SCHEME && token.present? Rails.application.(:llamabot_ws).verify(token) true rescue ActiveSupport::MessageVerifier::InvalidSignature false end |
#should_check_agent_auth? ⇒ Boolean
Public helper: true if the request carries a valid agent token
60 61 62 63 64 65 66 |
# File 'lib/llama_bot_rails/agent_auth.rb', line 60 def should_check_agent_auth? # Skip agent authentication entirely if a Devise user is already signed in return false if devise_user_signed_in? # Only check for LlamaBot requests if no Devise user is signed in llama_bot_request? end |