Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit 350e9ac

Browse files
committed
Merged opf/openproject/refs/tags/v5.0.15 into opf/openproject-ce/release/5.0
2 parents d7c9370 + eb4d71e commit 350e9ac

File tree

6 files changed

+24
-4
lines changed

6 files changed

+24
-4
lines changed

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ GIT
6363

6464
GIT
6565
remote: https://github.com/opf/openproject-translations.git
66-
revision: 7d1810e56cbf8b9476e4fa018d7b94fc8dab6026
66+
revision: c5146cc45b62d11cc83329ce5e9ac6caf98f510e
6767
branch: stable/5
6868
specs:
69-
openproject-translations (5.0.14)
69+
openproject-translations (5.0.15)
7070
crowdin-api (~> 0.4.0)
7171
mixlib-shellout (~> 2.1.0)
7272
rails (~> 4.2.3)

app/controllers/application_controller.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,14 @@ def handle_unverified_request
8989
# is raised here, but is denied by disable_api.
9090
#
9191
# See http://stackoverflow.com/a/15350123 for more information on login CSRF.
92-
render_error status: 422, message: 'Invalid form authenticity token.' unless api_request?
92+
unless api_request?
93+
94+
# Check whether user have cookies enabled, otherwise they'll only be
95+
# greeted with the CSRF error upon login.
96+
message = I18n.t(:error_token_authenticity)
97+
message << ' ' + I18n.t(:error_cookie_missing) if openproject_cookie_missing?
98+
render_error status: 422, message: message
99+
end
93100
end
94101

95102
rescue_from ActionController::ParameterMissing do |exception|
@@ -193,6 +200,13 @@ def check_if_login_required
193200
require_login if Setting.login_required?
194201
end
195202

203+
# Checks if the session cookie is missing.
204+
# This is useful only on a second request
205+
def openproject_cookie_missing?
206+
request.cookies[OpenProject::Configuration['session_cookie_name']].nil?
207+
end
208+
helper_method :openproject_cookie_missing?
209+
196210
def log_requesting_user
197211
return unless Setting.log_requesting_user?
198212
login_and_mail = " (#{escape_for_logging(User.current.login)} ID: #{User.current.id} " \

config/configuration.yml.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ default:
194194
# autologin_cookie_path:
195195
# autologin_cookie_secure:
196196

197+
# Configuration of the session cookie
198+
# session_cookie_name: the name of the OpenProject cookie (default: _open_project_session)
199+
197200
# disable browser cache for security reasons
198201
# see: https://websecuritytool.codeplex.com/wikipage?title=Checks#http-cache-control-header-no-store
199202
# disable_browser_cache: true

config/initializers/session_store.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
relative_url_root = config['rails_relative_url_root'].presence
3636

3737
session_options = {
38-
key: '_open_project_session',
38+
key: config['session_cookie_name'],
3939
path: relative_url_root
4040
}
4141

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ en:
753753
error_can_not_remove_role: "This role is in use and cannot be deleted."
754754
error_can_not_reopen_work_package_on_closed_version: "A work package assigned to a closed version cannot be reopened"
755755
error_check_user_and_role: "Please choose a user and a role."
756+
error_cookie_missing: 'The OpenProject cookie is missing. Please ensure that cookies are enabled, as this application will not properly function without.'
757+
error_token_authenticity: 'Unable to verify Cross-Site Request Forgery token.'
756758
error_work_package_done_ratios_not_updated: "Work package done ratios not updated."
757759
error_work_package_not_found_in_project: "The work package was not found or does not belong to this project"
758760
error_must_be_project_member: "must be project member"

lib/open_project/configuration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ module Configuration
5454
'cache_memcache_server' => nil,
5555
# where to store session data
5656
'session_store' => :cache_store,
57+
'session_cookie_name' => '_open_project_session',
5758
# url-path prefix
5859
'rails_relative_url_root' => '',
5960
'rails_force_ssl' => false,

0 commit comments

Comments
 (0)