Updated .well-known routes

• Updated:
- .well-known routes
This commit is contained in:
mgabdev 2020-05-25 21:04:40 -04:00
parent 7b9f0a5580
commit ec499eb1b8
4 changed files with 4 additions and 49 deletions

View File

@ -2,18 +2,8 @@
module WellKnown
class HostMetaController < ActionController::Base
include RoutingHelper
before_action { response.headers['Vary'] = 'Accept' }
def show
@webfinger_template = "#{webfinger_url}?resource={uri}"
respond_to do |format|
format.xml { render content_type: 'application/xrd+xml' }
end
expires_in(3.days, public: true)
raise GabSocial::NotPermittedError
end
end
end

View File

@ -3,7 +3,7 @@
module WellKnown
class KeybaseProofConfigController < ActionController::Base
def show
render json: {}, serializer: ProofProvider::Keybase::ConfigSerializer
render json: {}, status: 404
end
end
end

View File

@ -2,43 +2,8 @@
module WellKnown
class WebfingerController < ActionController::Base
include RoutingHelper
before_action { response.headers['Vary'] = 'Accept' }
def show
@account = Account.find_local!(username_from_resource)
respond_to do |format|
format.any(:json, :html) do
render json: @account, serializer: WebfingerSerializer, content_type: 'application/jrd+json'
end
format.xml do
render content_type: 'application/xrd+xml'
end
end
expires_in(3.days, public: true)
rescue ActiveRecord::RecordNotFound
head 404
end
private
def username_from_resource
resource_user = resource_param
username, domain = resource_user.split('@')
if Rails.configuration.x.alternate_domains.include?(domain)
resource_user = "#{username}@#{Rails.configuration.x.local_domain}"
end
WebfingerResource.new(resource_user).username
end
def resource_param
params.require(:resource)
raise GabSocial::NotPermittedError
end
end
end

View File

@ -22,7 +22,7 @@ Rails.application.routes.draw do
tokens: 'oauth/tokens'
end
get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta
get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger
get '.well-known/change-password', to: redirect('/auth/edit')
get '.well-known/keybase-proof-config', to: 'well_known/keybase_proof_config#show'