pact-mock_service 2.11.0 → 2.12.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
  SHA256:
3
- metadata.gz: 747c96bb4d050f110fcce31d689e1d618bfca4bbd4ffcd80cb4cbfe9d2a73169
4
- data.tar.gz: 32383ee0cdb1aa0a91d631f12c9f666a44d931244aa31d55e53eb54657a0f0bb
3
+ metadata.gz: 5bbf7164320c9bac3a7095a73727fb1bc887e3e3900e5bea8ed9103ea5391c37
4
+ data.tar.gz: 7dcda5c9871021cbb95b7ccf27fba2ce9194d81c8fcdbd0c5525b87dece84c81
5
5
  SHA512:
6
- metadata.gz: 0b2df396720759af740955a36889fd8874d6a0bfa54e1f49a88c1d3d923399927847830476cc0e610701f4ec9a89f8bd1b67dc1a4f0ed1cc5b1185f2f6c16426
7
- data.tar.gz: a42b7aeedbc4cd54d8546be463eefef1bf63137c3c3bbdd7d84da433144b99a43dd48a1aafe8bd1df42165efd38f525a467765e749fe9d673d0110906da66722
6
+ metadata.gz: 1ea38269c2c3c075fcf526078cd30a640e1667df424c8bec2f1c1c38450ea4ade5eb08727b119f94051449fae2d92ba274f166102811db0a55e01cda4d1e5322
7
+ data.tar.gz: db1687563fc2e96fdadb86c737c9c534b0294b8d1454d373a43e732733f49f14e3483580beb8c72e74aa7c767d15b36cbfacf993706c6bf563c66ad24a145354
@@ -9,9 +9,12 @@ module Pact
9
9
 
10
10
  HTTP_ACCESS_CONTROL_REQUEST_METHOD = "HTTP_ACCESS_CONTROL_REQUEST_METHOD".freeze
11
11
  HTTP_ACCESS_CONTROL_REQUEST_HEADERS = "HTTP_ACCESS_CONTROL_REQUEST_HEADERS".freeze
12
+ ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials".freeze
12
13
  ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin".freeze
13
14
  ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods".freeze
14
15
  ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers".freeze
16
+ AUTHORIZATION = "authorization".freeze
17
+ COOKIE = "cookie".freeze
15
18
  HTTP_ORIGIN = "HTTP_ORIGIN".freeze
16
19
  ALL_METHODS = "DELETE, POST, GET, HEAD, PUT, TRACE, CONNECT, PATCH".freeze
17
20
  REQUEST_METHOD = "REQUEST_METHOD".freeze
@@ -35,6 +38,10 @@ module Pact
35
38
  ACCESS_CONTROL_ALLOW_METHODS => ALL_METHODS
36
39
  }
37
40
 
41
+ if is_request_with_credentials?(env)
42
+ cors_headers[ACCESS_CONTROL_ALLOW_CREDENTIALS] = "true"
43
+ end
44
+
38
45
  logger.info "Received OPTIONS request for mock service administration endpoint #{env[HTTP_ACCESS_CONTROL_REQUEST_METHOD]} #{env['PATH_INFO']}. Returning CORS headers: #{cors_headers}."
39
46
  [200, cors_headers, []]
40
47
  end
@@ -46,6 +53,11 @@ module Pact
46
53
  def is_administration_request? env
47
54
  (env[HTTP_ACCESS_CONTROL_REQUEST_HEADERS] || '').match(X_PACT_MOCK_SERVICE_REGEXP)
48
55
  end
56
+
57
+ def is_request_with_credentials? env
58
+ headers = (env[HTTP_ACCESS_CONTROL_REQUEST_HEADERS] || '').split(",").map { |header| header.strip.downcase }
59
+ headers.include?(AUTHORIZATION) || headers.include?(COOKIE)
60
+ end
49
61
  end
50
62
  end
51
63
  end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module MockService
3
- VERSION = "2.11.0"
3
+ VERSION = "2.12.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-mock_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.0
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-08-28 00:00:00.000000000 Z
15
+ date: 2018-10-03 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rack