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>
29 lines
696 B
Ruby
29 lines
696 B
Ruby
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
|