mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 13:15:40 +02:00
Create separate key for Bounces API
This commit is contained in:
parent
b892927f11
commit
1b6c451656
5 changed files with 14 additions and 7 deletions
|
@ -11,7 +11,7 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_shared_key
|
def authenticate_shared_key
|
||||||
api_key = "Basic #{ENV['internal_api_key']}"
|
api_key = "Basic #{ENV['rwhois_internal_api_shared_key']}"
|
||||||
head(:unauthorized) unless api_key == request.authorization
|
head(:unauthorized) unless api_key == request.authorization
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
class BouncesController < BaseController
|
class BouncesController < BaseController
|
||||||
before_action :authenticate_shared_key
|
before_action :validate_shared_key_integrity
|
||||||
|
|
||||||
# POST api/v1/bounces/
|
# POST api/v1/bounces/
|
||||||
def create
|
def create
|
||||||
|
@ -20,6 +20,13 @@ module Api
|
||||||
|
|
||||||
params.require(:data)
|
params.require(:data)
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,11 +87,11 @@ sk_digi_doc_service_name: 'Testimine'
|
||||||
registrant_api_base_url:
|
registrant_api_base_url:
|
||||||
registrant_api_auth_allowed_ips: '127.0.0.1, 0.0.0.0' #ips, separated with commas
|
registrant_api_auth_allowed_ips: '127.0.0.1, 0.0.0.0' #ips, separated with commas
|
||||||
|
|
||||||
# Bounces API
|
# Shared key for REST-WHOIS Bounces API incl. CERT
|
||||||
api_shared_key: testkey
|
rwhois_bounces_api_shared_key: testkey
|
||||||
|
|
||||||
# Link to REST-WHOIS API
|
# Link to REST-WHOIS API
|
||||||
internal_api_key: testkey
|
rwhois_internal_api_shared_key: testkey
|
||||||
|
|
||||||
# Base URL (inc. https://) of REST registrant portal
|
# Base URL (inc. https://) of REST registrant portal
|
||||||
# Leave blank to use internal registrant portal
|
# Leave blank to use internal registrant portal
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'test_helper'
|
||||||
|
|
||||||
class BouncesApiV1CreateTest < ActionDispatch::IntegrationTest
|
class BouncesApiV1CreateTest < ActionDispatch::IntegrationTest
|
||||||
def setup
|
def setup
|
||||||
@api_key = "Basic #{ENV['api_shared_key']}"
|
@api_key = "Basic #{ENV['rwhois_bounces_api_shared_key']}"
|
||||||
@headers = { "Authorization": "#{@api_key}" }
|
@headers = { "Authorization": "#{@api_key}" }
|
||||||
@json_body = { "data": valid_bounce_request }.as_json
|
@json_body = { "data": valid_bounce_request }.as_json
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'test_helper'
|
||||||
|
|
||||||
class ApiV1ContactRequestTest < ActionDispatch::IntegrationTest
|
class ApiV1ContactRequestTest < ActionDispatch::IntegrationTest
|
||||||
def setup
|
def setup
|
||||||
@api_key = "Basic #{ENV['api_shared_key']}"
|
@api_key = "Basic #{ENV['rwhois_internal_api_shared_key']}"
|
||||||
@headers = { "Authorization": "#{@api_key}" }
|
@headers = { "Authorization": "#{@api_key}" }
|
||||||
@json_create = { "contact_request": valid_contact_request_create }.as_json
|
@json_create = { "contact_request": valid_contact_request_create }.as_json
|
||||||
@json_update = { "contact_request": valid_contact_request_update }.as_json
|
@json_update = { "contact_request": valid_contact_request_update }.as_json
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue