Skip to content

Commit 9a5ca59

Browse files
committed
[*] Security - Fix implementation of session token passed in headers while downloading collections records
1 parent 869f263 commit 9a5ca59

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Change Log
22

33
## [Unreleased]
4+
### Fixed
5+
- Security - Fix implementation of session token passed in headers while downloading collections records.
46

57
## RELEASE 3.0.0-beta.15 - 2019-03-27
68
### Changed

app/controllers/forest_liana/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
module ForestLiana
55
class ApplicationController < ForestLiana::BaseController
6-
REGEX_COOKIE_SESSION_TOKEN = /sessionToken=(.*);?/;
6+
REGEX_COOKIE_SESSION_TOKEN = /forest_session_token=([^;]*)/;
77

88
def self.papertrail?
99
Object.const_get('PaperTrail::Version').is_a?(Class) rescue false

app/controllers/forest_liana/sessions_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ def process_login(
8282

8383
render(serializer: nil, json: nil, status: :internal_server_error)
8484
else
85+
# NOTICE: Set a cookie to ensure secure authentication using export feature.
86+
# NOTICE: The token is empty at first authentication step if the 2FA option is active.
87+
response.set_cookie("forest_session_token", reponse_data[:token]) if reponse_data[:token]
88+
8589
render(json: reponse_data, serializer: nil)
8690
end
8791
end

lib/forest_liana/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def configure_forest_cors
2323
hostnames += ENV['CORS_ORIGINS'].split(',') if ENV['CORS_ORIGINS']
2424

2525
origins hostnames
26-
resource '*', headers: :any, methods: :any, max_age: 86400 # NOTICE: 1 day
26+
resource '*', headers: :any, methods: :any, credentials: true, max_age: 86400 # NOTICE: 1 day
2727
end
2828
end
2929
nil

0 commit comments

Comments
 (0)