mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Implement shared key authentication to bounces API
This commit is contained in:
parent
b2c5a9a5ec
commit
03182f9222
3 changed files with 11 additions and 1 deletions
|
@ -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' }
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
module Api
|
||||
module V1
|
||||
class BouncesController < BaseController
|
||||
before_action :authenticate_shared_key
|
||||
|
||||
# POST api/v1/bounces/
|
||||
def create
|
||||
BouncedMailAddress.record(bounce_params)
|
||||
head(:ok)
|
||||
head(:created)
|
||||
rescue ActionController::ParameterMissing
|
||||
head(:bad_request)
|
||||
end
|
||||
|
|
|
@ -87,6 +87,9 @@ sk_digi_doc_service_name: 'Testimine'
|
|||
registrant_api_base_url:
|
||||
registrant_api_auth_allowed_ips: '127.0.0.1, 0.0.0.0' #ips, separated with commas
|
||||
|
||||
# Bounces API
|
||||
api_shared_key: testkey
|
||||
|
||||
#
|
||||
# MISC
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue