include AccountControllerConcern
include SignatureAuthentication
+ before_action :require_signature!, if: -> { request.format == :json && authorized_fetch_mode? }
before_action :set_cache_headers
before_action :set_body_classes
format.json do
expires_in 3.minutes, public: !(authorized_fetch_mode? && signed_request_account.present?)
- render_with_cache json: @account, content_type: 'application/activity+json', serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter, fields: restrict_fields_to
+ render_with_cache json: @account, content_type: 'application/activity+json', serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter
end
end
end
def params_slice(*keys)
params.slice(*keys).permit(*keys)
end
-
- def restrict_fields_to
- if signed_request_account.present? || public_fetch_mode?
- # Return all fields
- else
- %i(id type preferred_username inbox public_key endpoints)
- end
- end
end
context 'in authorized fetch mode' do
let(:authorized_fetch_mode) { true }
- it 'returns http success' do
- expect(response).to have_http_status(200)
- end
-
- it 'returns application/activity+json' do
- expect(response.content_type).to eq 'application/activity+json'
- end
-
- it_behaves_like 'cachable response'
-
- it 'returns Vary header with Signature' do
- expect(response.headers['Vary']).to include 'Signature'
- end
-
- it 'renders bare minimum account' do
- json = body_as_json
- expect(json).to include(:id, :type, :preferredUsername, :inbox, :publicKey)
- expect(json).to_not include(:name, :summary)
+ it 'returns http unauthorized' do
+ expect(response).to have_http_status(401)
end
end
end