Skip to content

Commit 2174791

Browse files
[-] Security - Do not pass session token in query params while downloading collections records (#309)
1 parent c58c2c4 commit 2174791

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
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+
### Changed
5+
- Security - Do not pass session token in query params while downloading collections records.
46

57
## RELEASE 3.0.0-beta.14 - 2019-03-01
68
### Fixed

app/controllers/forest_liana/application_controller.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
module ForestLiana
55
class ApplicationController < ForestLiana::BaseController
6+
REGEX_COOKIE_SESSION_TOKEN = /sessionToken=(.*);?/;
7+
68
def self.papertrail?
79
Object.const_get('PaperTrail::Version').is_a?(Class) rescue false
810
end
@@ -56,11 +58,13 @@ def serialize_models(records, options = {}, fields_searched = [])
5658

5759
def authenticate_user_from_jwt
5860
begin
59-
if request.headers['Authorization'] || params['sessionToken']
61+
if request.headers
6062
if request.headers['Authorization']
6163
token = request.headers['Authorization'].split.second
62-
else
63-
token = params['sessionToken']
64+
# NOTICE: Necessary for downloads authentication.
65+
elsif request.headers['cookie']
66+
match = REGEX_COOKIE_SESSION_TOKEN.match(request.headers['cookie'])
67+
token = match[1] if match && match[1]
6468
end
6569

6670
@jwt_decoded_token = JWT.decode(token, ForestLiana.auth_secret, true,

0 commit comments

Comments
 (0)