license updating
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -37,6 +37,7 @@ pickle-email-*.html
|
|||||||
.rbenv-version
|
.rbenv-version
|
||||||
config/deploy/config/*
|
config/deploy/config/*
|
||||||
config/puma.rb
|
config/puma.rb
|
||||||
|
config/shops.json
|
||||||
!/log/.keep
|
!/log/.keep
|
||||||
!/tmp/.keep
|
!/tmp/.keep
|
||||||
.ruby-version
|
.ruby-version
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ class License
|
|||||||
end
|
end
|
||||||
|
|
||||||
def detail_with_local_cache(lookup)
|
def detail_with_local_cache(lookup)
|
||||||
|
|
||||||
|
aes = MyAesCrypt.new
|
||||||
|
aes_key, aes_iv = aes.export_to_file(lookup)
|
||||||
# flag = ENV["AES_IV"]
|
# flag = ENV["AES_IV"]
|
||||||
# # Check Exists IV
|
# # Check Exists IV
|
||||||
# if flag == "<%= ENV['AES_IV'] %>"
|
# if flag == "<%= ENV['AES_IV'] %>"
|
||||||
@@ -36,8 +38,8 @@ class License
|
|||||||
# aes_iv = ENV["AES_IV"]
|
# aes_iv = ENV["AES_IV"]
|
||||||
# end
|
# end
|
||||||
##Check from local redis - if available load local otherwise get from remote
|
##Check from local redis - if available load local otherwise get from remote
|
||||||
cache_key = "#{lookup}:license:#{key}:hostname"
|
cache_key = "#{lookup}:license:#{aes_key}:hostname"
|
||||||
|
byebug
|
||||||
# No Needs for current
|
# No Needs for current
|
||||||
# @secret = key
|
# @secret = key
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ class License
|
|||||||
if cache_license.nil?
|
if cache_license.nil?
|
||||||
##change the d/e key
|
##change the d/e key
|
||||||
# @options = { query: {device: "SXlite", lookup: lookup, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
|
# @options = { query: {device: "SXlite", lookup: lookup, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
|
||||||
@params = { query: { lookup_type: self.server_mode, lookup: lookup, iv_key: iv} }
|
@params = { query: { lookup_type: self.server_mode, lookup: lookup, iv_key: aes_iv} }
|
||||||
response = self.class.get("/subdomain", @params)
|
response = self.class.get("/subdomain", @params)
|
||||||
@license = response.parsed_response
|
@license = response.parsed_response
|
||||||
|
|
||||||
|
|||||||
@@ -31,15 +31,35 @@ class MyAesCrypt
|
|||||||
file_path = "config/shops.json"
|
file_path = "config/shops.json"
|
||||||
aes_key, aes_iv = export_key(passphrase)
|
aes_key, aes_iv = export_key(passphrase)
|
||||||
tmpHash = {
|
tmpHash = {
|
||||||
"lookup" => passphrase,
|
"lookup" => passphrase = {
|
||||||
"key" => aes_key,
|
"key" => aes_key,
|
||||||
"iv" => aes_iv
|
"iv" => aes_iv
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File.open(file_path, "w") { |io|
|
shop_data = File.read(file_path)
|
||||||
io.write(tmpHash.to_json)
|
if shop_data != ""
|
||||||
}
|
shop_json = JSON.parse(shop_data)
|
||||||
|
byebug
|
||||||
|
shop_json.each do |j|
|
||||||
|
if j == passphrase
|
||||||
|
j.each do |k|
|
||||||
|
return k["key"], k["iv"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
shop_json << tmpHash
|
||||||
|
|
||||||
|
File.open(file_path, "w") { |io|
|
||||||
|
io.puts JSON.pretty_generate(shop_json)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
File.open(file_path, "w") { |io|
|
||||||
|
io.write(tmpHash.to_json)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
return aes_key, aes_iv
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
development:
|
development:
|
||||||
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
||||||
sx_provision_url: 192.168.1.147:3002/api #connect.smartsales.asia/api #provision.zsai.ws/api
|
sx_provision_url: 192.168.1.147:3002/api #connect.smartsales.asia/api #provision.zsai.ws/api
|
||||||
server_mode: application
|
server_mode: cloud
|
||||||
cipher_type: AES-256-CBC
|
cipher_type: AES-256-CBC
|
||||||
sx_key: Wh@t1$C2L
|
sx_key: Wh@t1$C2L
|
||||||
aes_key: <%= ENV['AES_KEY'] %>
|
aes_key: <%= ENV['AES_KEY'] %>
|
||||||
|
|||||||
Reference in New Issue
Block a user