Espone API JSON e MCP HTTP per far lavorare gli agenti sul CRM.
Gli agenti autenticati con token Bearer possono leggere today/pipeline e annotare attività, con host MCP allineati a quelli di produzione. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
module Api
|
||||
class BaseController < ActionController::API
|
||||
wrap_parameters false
|
||||
before_action :authenticate_api_token!
|
||||
|
||||
attr_reader :current_user, :current_api_token
|
||||
|
||||
private
|
||||
|
||||
def authenticate_api_token!
|
||||
token = ApiToken.authenticate(bearer_token)
|
||||
unless token
|
||||
render json: { error: "Non autenticato" }, status: :unauthorized
|
||||
return
|
||||
end
|
||||
|
||||
@current_api_token = token
|
||||
@current_user = token.user
|
||||
Current.user = @current_user
|
||||
token.touch_last_used!
|
||||
end
|
||||
|
||||
def bearer_token
|
||||
header = request.authorization.to_s.presence || request.headers["Authorization"].to_s
|
||||
header[/Bearer\s+(.+)/i, 1]
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user