Class: Xeno::SlackController
- Inherits:
-
ApiController
- Object
- ActionController::API
- ApiController
- Xeno::SlackController
- Defined in:
- app/controllers/xeno/slack_controller.rb
Overview
The Slack Events API endpoint. The generic auth lambda is skipped — Slack's own request signature IS the authentication (verified in constant time), and it fails closed: no configured slack channel = 404, bad or stale signature = 401.
Constant Summary
Constants inherited from ApiController
Instance Method Summary collapse
Instance Method Details
#events ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/xeno/slack_controller.rb', line 9 def events channel = Channels.registry[:slack] return head :not_found unless channel raw = request.raw_post unless channel.verify_signature( request.headers["X-Slack-Request-Timestamp"], request.headers["X-Slack-Signature"], raw ) return head :unauthorized end payload = JSON.parse(raw) return render json: { challenge: payload["challenge"] } if payload["type"] == "url_verification" enqueue_event(payload) head :ok end |