mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 05:26:17 +02:00
change acceptable tokens
This commit is contained in:
parent
c54c89baf7
commit
204629a62b
3 changed files with 14 additions and 10 deletions
|
@ -6,6 +6,8 @@ module EisBilling
|
||||||
before_action :persistent
|
before_action :persistent
|
||||||
before_action :authorized
|
before_action :authorized
|
||||||
|
|
||||||
|
INITIATOR = 'billing'.freeze
|
||||||
|
|
||||||
def encode_token(payload)
|
def encode_token(payload)
|
||||||
JWT.encode(payload, ENV['secret_word'])
|
JWT.encode(payload, ENV['secret_word'])
|
||||||
end
|
end
|
||||||
|
@ -19,7 +21,7 @@ module EisBilling
|
||||||
if auth_header
|
if auth_header
|
||||||
token = auth_header.split(' ')[1]
|
token = auth_header.split(' ')[1]
|
||||||
begin
|
begin
|
||||||
JWT.decode(token, ENV['secret_word'], true, algorithm: 'HS256')
|
JWT.decode(token, billing_secret_key, true, algorithm: 'HS256')
|
||||||
rescue JWT::DecodeError
|
rescue JWT::DecodeError
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
@ -27,9 +29,9 @@ module EisBilling
|
||||||
end
|
end
|
||||||
|
|
||||||
def accessable_service
|
def accessable_service
|
||||||
if decoded_token
|
return decoded_token[0]['initiator'] == INITIATOR if decoded_token
|
||||||
decoded_token[0]['data'] == ENV['secret_access_word']
|
|
||||||
end
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def logged_in?
|
def logged_in?
|
||||||
|
@ -40,12 +42,12 @@ module EisBilling
|
||||||
render json: { message: 'Access denied' }, status: :unauthorized unless logged_in?
|
render json: { message: 'Access denied' }, status: :unauthorized unless logged_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
def logger
|
def billing_secret_key
|
||||||
Rails.logger
|
Rails.application.credentials.config[:billing_secret]
|
||||||
end
|
end
|
||||||
|
|
||||||
def logger
|
def logger
|
||||||
@logger ||= Rails.logger
|
Rails.logger
|
||||||
end
|
end
|
||||||
|
|
||||||
def persistent
|
def persistent
|
||||||
|
|
|
@ -7,7 +7,7 @@ module EisBilling
|
||||||
uri = URI(url)
|
uri = URI(url)
|
||||||
http = Net::HTTP.new(uri.host, uri.port)
|
http = Net::HTTP.new(uri.host, uri.port)
|
||||||
|
|
||||||
unless Rails.env.development? || Rails.env.test?
|
if Rails.env.production?
|
||||||
http.use_ssl = true
|
http.use_ssl = true
|
||||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||||
end
|
end
|
||||||
|
|
|
@ -235,8 +235,10 @@ registry_demo_accredited_users_url: 'http://registry.test/api/v1/accreditation_c
|
||||||
a_and_aaaa_validation_timeout: '1'
|
a_and_aaaa_validation_timeout: '1'
|
||||||
nameserver_validation_timeout: '1'
|
nameserver_validation_timeout: '1'
|
||||||
|
|
||||||
eis_billing_system_base_url_dev: 'http://eis_billing_system:3000'
|
eis_billing_system_base_url: 'http://eis_billing_system:3000'
|
||||||
eis_billing_system_base_url_staging: 'https://st-billing.infra.tld.ee'
|
|
||||||
secret_access_word: 'please-Give-Me-accesS'
|
secret_access_word: 'please-Give-Me-accesS'
|
||||||
secret_word: 'this-secret-should-be-change'
|
secret_word: 'this-secret-should-be-change'
|
||||||
billing_system_integrated: 'true'
|
billing_system_integrated: 'true'
|
||||||
|
allow_accr_endspoints: 'true'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue