active_elastic_job 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 295868f33a251b59a3dfe4cfd54c8f1dd2180873
|
4
|
+
data.tar.gz: 323dff4ad944340e11f8819d5c5f2d28f1ead982
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a5cac45a1460d5e5b8865db125fbd2684807d5d6fd71e2ca6c967459a0d3fcba895c062e7d10250dac038743694148ba05366538d7d09ba6688b0fda285c207
|
7
|
+
data.tar.gz: a57f088927d4efb9f8906cc75ccac279da3ae96298633a42dc54fd94e804b213cfe6edda11fac91961a82b49c47753aab64dad96dd23a13561ae2c611082e7ab
|
@@ -19,6 +19,8 @@ module ActiveElasticJob
|
|
19
19
|
CONTENT_TYPE = 'application/json'.freeze
|
20
20
|
CONTENT_TYPE_HEADER_NAME = 'Content-Type'.freeze
|
21
21
|
OK_RESPONSE_CODE = '200'.freeze
|
22
|
+
INSIDE_DOCKER_CONTAINER = `cat /proc/1/cgroup` =~ /docker/
|
23
|
+
DOCKER_HOST_IP = "172.17.0.1".freeze
|
22
24
|
|
23
25
|
def initialize(app) #:nodoc:
|
24
26
|
@app = app
|
@@ -27,7 +29,7 @@ module ActiveElasticJob
|
|
27
29
|
def call(env) #:nodoc:
|
28
30
|
request = ActionDispatch::Request.new env
|
29
31
|
if enabled? && aws_sqsd?(request) && originates_from_gem?(request)
|
30
|
-
unless request.local?
|
32
|
+
unless request.local? || sent_from_docker_host?(request)
|
31
33
|
m = "Accepts only requests from localhost for job processing".freeze
|
32
34
|
return ['403', {CONTENT_TYPE_HEADER_NAME => 'text/plain' }, [ m ]]
|
33
35
|
end
|
@@ -86,6 +88,10 @@ module ActiveElasticJob
|
|
86
88
|
return false
|
87
89
|
end
|
88
90
|
end
|
91
|
+
|
92
|
+
def sent_from_docker_host?(request)
|
93
|
+
INSIDE_DOCKER_CONTAINER && request.remote_ip == DOCKER_HOST_IP
|
94
|
+
end
|
89
95
|
end
|
90
96
|
end
|
91
97
|
end
|
@@ -171,9 +171,10 @@ module ActiveJob
|
|
171
171
|
end
|
172
172
|
|
173
173
|
def aws_sqs_client
|
174
|
+
@aws_key ||= ENV['AWS_SECRET_ACCESS_KEY'] || ENV['AWS_SECRET_KEY'] || ENV['AMAZON_SECRET_ACCESS_KEY']
|
174
175
|
@aws_sqs_client ||= Aws::SQS::Client.new(
|
175
176
|
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
176
|
-
secret_access_key:
|
177
|
+
secret_access_key: @aws_key,
|
177
178
|
region: ENV['AWS_REGION']
|
178
179
|
)
|
179
180
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_elastic_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tawan Sierek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|