OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/lib/open_project/authentication/strategies/warden/session.rb

39 lines
1021 B

require 'open_project/authentication/session_expiry'
module OpenProject
module Authentication
module Strategies
module Warden
##
# Temporary strategy necessary as long as the OpenProject authentication has
# not been unified in terms of Warden strategies and is only locally
# applied to the API v3.
class Session < ::Warden::Strategies::Base
include ::OpenProject::Authentication::SessionExpiry
def valid?
session && !session_ttl_expired? && xml_request_header_set?
end
def authenticate!
user = user_id ? User.find(user_id) : User.anonymous
success! user
end
def xml_request_header_set?
request.env['HTTP_X_REQUESTED_WITH'.freeze] == 'XMLHttpRequest'.freeze
end
def user_id
Hash(session)['user_id']
end
def session
env['rack.session']
end
end
end
end
end
end