use SHARED_IMPORT_SECRET

This commit is contained in:
Joerg Reichert 2023-04-29 22:58:51 +02:00
parent 19c29ef021
commit ac5350c461
6 changed files with 12 additions and 5 deletions

1
.gitignore vendored
View file

@ -14,7 +14,6 @@
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
config/morph.yml
/coverage
.vagrant
/node_modules

View file

@ -4,14 +4,21 @@ class ImportController < ApplicationController
skip_before_action :verify_authenticity_token, only: [:new_papers_callback]
def new_papers_callback
received_secret = params[:secret]
expected_secret = Rails.application.config.shared_import_secret
if received_secret != expected_secret
print("secrets not match")
return
end
require 'open-uri'
#api_key = Rails.application.config_for(:morph)['key']
#uri = URI.parse("https://api.morph.io/jrlover/city_council_leipzig_recent_papers/data.json?key=#{api_key}&query=select%20*%20from%20%27data%27")
print("before parse")
uri = URI.parse("https://joergreichert.de/srm/input.json")
print("after parse")
#Paper.import_from_json(uri.read)
Paper.import_from_json(uri.read)
print("after import")
render nothing: true
head :no_content
end
end

View file

@ -41,4 +41,5 @@ Rails.application.configure do
$stdout.sync = true
config.hosts = ENV['APPLICATION_HOST'] || 'localhost'
config.shared_import_secret = ENV['SHARED_IMPORT_SECRET']
end

View file

@ -77,4 +77,5 @@ Rails.application.configure do
config.active_record.dump_schema_after_migration = false
config.hosts = ENV['APPLICATION_HOST'] || 'stadtratmonitor.leipzig.codefor.de'
config.shared_import_secret = ENV['SHARED_IMPORT_SECRET']
end

View file

@ -1,2 +0,0 @@
development:
key: insertyourkeyhere

View file

@ -12,6 +12,7 @@ services:
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
- APPLICATION_HOST=$APPLICATION_HOST
- SHARED_IMPORT_SECRET=$SHARED_IMPORT_SECRET
command: sh -c "cd /home/srm/app && bundle exec puma -C config/puma.rb"
elasticsearch:
user: elasticsearch