datadome_module 1.0.0 → 1.1.1

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: 4c5a567ef1e14370ded3cd576bdb8159f84f38eb4edbd09dc5feb0dbe81ed97f
4
- data.tar.gz: f17d7fad02f793d1ccd076abad21f58197e617cd419484c06d1bb266ac3721cf
3
+ metadata.gz: 5ddfcfecfd9f51f333f9e40f60c5bff1f68d6fa1c0f23e4cf25f7f75bc3ed87b
4
+ data.tar.gz: 1bfa3743ddd6c69b0eab8f9421e60f32d2da1709410760847c163d2e324bd7ee
5
5
  SHA512:
6
- metadata.gz: e2c2460a111020f008b9c15e3d16b47235474db529fb3b9bce5407b310b3f68ca016e4dd9d52407fcc63c42120223e4693fed14993b575c928e7721f77419799
7
- data.tar.gz: 96a905735e3377be315363208f781c9ff7214c04e4b2ad04766c7688974c07a99e5e8efcdd3f0e3cd01e210cec48b7995b21d86f75875ab8a2087bd8137cffbd
6
+ metadata.gz: 9d694c9960ff4b9969adfa20360699d85d4bb24592bdaa8db8c360b1c1304707da1a55025b76852dde20d483a2d950e664e64ad0a4e5e80d26f221776a82d316
7
+ data.tar.gz: 7b956519b3558cc669d4e60068788e200d86049c26ad6f38f8740316c5198b27e1039eb26484fb123d3dac64cccf3b697c6395edfce3aacb939a007be873544c
data/lib/constants.rb CHANGED
@@ -1,4 +1,4 @@
1
- MODULE_VERSION = '1.0.0'
1
+ MODULE_VERSION = '1.1.1'
2
2
  MODULE_NAME = 'datadome_module'
3
3
 
4
4
  VALIDATE_REQUEST_PATH = '/validate-request'
@@ -24,7 +24,24 @@ class DataDomeModule
24
24
  return assessment_result.response_array unless assessment_result.legitimate_request?
25
25
 
26
26
  status, headers, payload = @app.call(env)
27
- headers = headers.merge(assessment_result.headers)
27
+
28
+ # Merge the headers from DataDome with the original headers
29
+ headers = headers.merge(assessment_result.headers) do |key, request_header_val, datadome_header_val|
30
+ if key.downcase == "set-cookie" && request_header_val
31
+ # Handle the merge for cookies when the protected request has at least one cookie
32
+ # If the original request contains one cookie, ensure it's in an array format for uniform handling
33
+ request_header_val = [request_header_val] unless request_header_val.is_a?(Array)
34
+
35
+ # Remove any cookies that start with 'datadome=' from the original request's cookies
36
+ request_header_val.reject! { |cookie| cookie.downcase.start_with?("datadome=") }
37
+
38
+ # Return the cookies merged with the new value of the datadome cookie
39
+ [datadome_header_val, *request_header_val]
40
+ else
41
+ # For DataDome headers other than 'Set-Cookie', return the value.
42
+ datadome_header_val
43
+ end
44
+ end
28
45
 
29
46
  [status, headers, payload]
30
47
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datadome_module
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - DataDome
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-20 00:00:00.000000000 Z
11
+ date: 2024-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.8'
26
+ version: '0'
27
27
  description: Used to assess requests with DataDome Protection API.
28
28
  email: support@datadome.co
29
29
  executables: []