Create separate key for Bounces API

This commit is contained in:
Karl Erik Õunapuu 2021-02-10 12:17:32 +02:00
parent b892927f11
commit 1b6c451656
No known key found for this signature in database
GPG key ID: C9DD647298A34764
5 changed files with 14 additions and 7 deletions

View file

@ -1,7 +1,7 @@
module Api
module V1
class BouncesController < BaseController
before_action :authenticate_shared_key
before_action :validate_shared_key_integrity
# POST api/v1/bounces/
def create
@ -20,6 +20,13 @@ module Api
params.require(:data)
end
private
def validate_shared_key_integrity
api_key = "Basic #{ENV['rwhois_bounces_api_shared_key']}"
head(:unauthorized) unless api_key == request.authorization
end
end
end
end