oauth_metadata_controller.rb 789 B

1234567891011121314151617181920212223
  1. # frozen_string_literal: true
  2. module WellKnown
  3. class OauthMetadataController < ActionController::Base # rubocop:disable Rails/ApplicationController
  4. include CacheConcern
  5. # Prevent `active_model_serializer`'s `ActionController::Serialization` from calling `current_user`
  6. # and thus re-issuing session cookies
  7. serialization_scope nil
  8. def show
  9. # Due to this document potentially changing between Mastodon versions (as
  10. # new OAuth scopes are added), we don't use expires_in to cache upstream,
  11. # instead just caching in the rails cache:
  12. render_with_cache(
  13. json: ::OauthMetadataPresenter.new,
  14. serializer: ::OauthMetadataSerializer,
  15. content_type: 'application/json',
  16. expires_in: 15.minutes
  17. )
  18. end
  19. end
  20. end