Class: ActionMCP::GatewayIdentifiers::WardenIdentifier

Inherits:
ActionMCP::GatewayIdentifier show all
Defined in:
lib/action_mcp/gateway_identifiers/warden_identifier.rb

Overview

Example Gateway identifier for Warden-based authentication.

This identifier works with Warden middleware which is commonly used by Devise. Warden sets the authenticated user in request.env after successful authentication.

Examples:

Usage in ApplicationGateway

class ApplicationGateway < ActionMCP::Gateway
  identified_by ActionMCP::GatewayIdentifiers::WardenIdentifier
end

Configuration

# config/mcp.yml
authentication_methods: ["warden"]

With Devise

# In your controller or middleware, ensure Warden is configured:
# devise_for :users
# authenticate_user! # This sets up Warden env

Instance Method Summary collapse

Methods inherited from ActionMCP::GatewayIdentifier

authenticates, identifier, #initialize

Constructor Details

This class inherits a constructor from ActionMCP::GatewayIdentifier

Instance Method Details

#resolveObject

Raises:



27
28
29
30
31
32
33
34
35
# File 'lib/action_mcp/gateway_identifiers/warden_identifier.rb', line 27

def resolve
  warden = @request.env["warden"]
  raise Unauthorized, "Warden not available" unless warden

  user = warden.user
  raise Unauthorized, "Not authenticated" unless user

  user
end