Implement shared key authentication to bounces API

This commit is contained in:
Karl Erik Õunapuu 2020-09-17 16:26:50 +03:00
parent b2c5a9a5ec
commit 03182f9222
No known key found for this signature in database
GPG key ID: C9DD647298A34764
3 changed files with 11 additions and 1 deletions

View file

@ -10,6 +10,11 @@ module Api
head :unauthorized unless ip_allowed
end
def authenticate_shared_key
api_key = "Basic #{ENV['api_shared_key']}"
head(:unauthorized) unless api_key == request.authorization
end
def not_found_error
uuid = params['uuid']
json = { error: 'Not Found', uuid: uuid, message: 'Record not found' }