Skip to content

Commit 85d7c4e

Browse files
author
Inbal Tako
committed
Support sinatra extraction
1 parent 3a7cab4 commit 85d7c4e

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

lib/context/hanami_context.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ def self.get_client_token(request)
77
begin
88
request.env[SECURENATIVE_COOKIE]
99
rescue StandardError
10-
nil
10+
begin
11+
request.cookies[SECURENATIVE_COOKIE]
12+
rescue StandardError
13+
nil
14+
end
1115
end
1216
end
1317

lib/context/rails_context.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def self.get_method(request)
3535

3636
def self.get_headers(request)
3737
begin
38-
# Note: At the moment we're filtering out everything but user-agent since rails payload is way too big
38+
# Note: At the moment we're filtering out everything but user-agent since ruby's payload is way too big
3939
{"user-agent" => request.headers['HTTP_USER_AGENT']}
4040
rescue StandardError
4141
nil

lib/context/sinatra_context.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,34 @@ def self.get_client_token(request)
77
begin
88
request.env[SECURENATIVE_COOKIE]
99
rescue StandardError
10-
nil
10+
begin
11+
request.cookies[SECURENATIVE_COOKIE]
12+
rescue StandardError
13+
nil
14+
end
1115
end
1216
end
1317

1418
def self.get_url(request)
1519
begin
16-
request.url
20+
request.env['REQUEST_URI']
1721
rescue StandardError
1822
nil
1923
end
2024
end
2125

2226
def self.get_method(request)
2327
begin
24-
request.method
28+
request.env['REQUEST_METHOD']
2529
rescue StandardError
2630
nil
2731
end
2832
end
2933

3034
def self.get_headers(request)
3135
begin
32-
request.headers.to_h
36+
# Note: At the moment we're filtering out everything but user-agent since ruby's payload is way too big
37+
{"user-agent" => request.env['HTTP_USER_AGENT']}
3338
rescue StandardError
3439
nil
3540
end

lib/models/verify_result.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ def initialize(risk_level: nil, score: nil, triggers: nil)
99
@score = score
1010
@triggers = triggers
1111
end
12+
13+
def to_s
14+
"risk_level: #{@risk_level}, score: #{@score}, triggers: #{@triggers}"
15+
end
1216
end

0 commit comments

Comments
 (0)