4d85c27d1a
Several controlers set quite intricate Cache-Control headers in order to
hopefully not be cached by any intermediate proxies or local caches. Unfortunately,
these headers are processed by ActionDispatch::HTTP::Cache in a way that squashes
and discards any values set alongside no-store other than private:
8015c2c2cf/actionpack/lib/action_dispatch/http/cache.rb (L207-L209)
We want to preserve no-store on these responses, but we might as well remove
parts that are going to be dropped anyway. As many of the endpoints in these
controllers are private to a particular user, we should also add "private",
which will be preserved alongside no-store.
35 lines
832 B
Ruby
35 lines
832 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
|
|
skip_before_action :authenticate_resource_owner!
|
|
|
|
before_action :store_current_location
|
|
before_action :authenticate_resource_owner!
|
|
before_action :set_cache_headers
|
|
|
|
include Localized
|
|
|
|
private
|
|
|
|
def store_current_location
|
|
store_location_for(:user, request.url)
|
|
end
|
|
|
|
def render_success
|
|
if skip_authorization? || (matching_token? && !truthy_param?('force_login'))
|
|
redirect_or_render authorize_response
|
|
elsif Doorkeeper.configuration.api_only
|
|
render json: pre_auth
|
|
else
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def truthy_param?(key)
|
|
ActiveModel::Type::Boolean.new.cast(params[key])
|
|
end
|
|
|
|
def set_cache_headers
|
|
response.headers['Cache-Control'] = 'private, no-store'
|
|
end
|
|
end
|