Skip to content

Fetch payload body from params[:notification]

Vitali Tatarintev requested to merge refactor-generic-alerts-endpoint into master

What does this MR do?

Related to the Generic Alert Endpoint.

Fetch payload body from params[:notification] instead of slicing out service params such as controller, and action names.

If the "Content-Type" header of your request is set to "application/json", Rails will automatically load your parameters into the params hash, which you can access as you would normally.

https://guides.rubyonrails.org/v5.2/action_controller_overview.html#json-parameters

Request example

→ curl --request POST --data '{"title": "Incident title"}' --header "Authorization: Bearer randomtoken" --header "Content-Type: application/json" http://localhost:3000/ck3g/playground/alerts/notify


<ActionController::Parameters {"title"=>"Incident title", "controller"=>"projects/alerting/notifications", "action"=>"create", "namespace_id"=>"ck3g", "project_id"=>"playground", "notification"=>{"title"=>"Incident title"}} permitted: false>

Does this MR meet the acceptance criteria?

Conformity

Performance and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • ~~Label as security and @ mention @gitlab-com/gl-security/appsec~~
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Vitali Tatarintev

Merge request reports