0
0
Fork 0

Webfinger resource to extract username from resource string (#1607)

* Add WebfingerResource class to extract usernames

* Use WebfingerResource in xrd#webfinger
This commit is contained in:
Matt Jankowski 2017-04-12 12:22:38 -04:00 committed by Eugen
parent 0930ce5560
commit aa90798386
3 changed files with 155 additions and 9 deletions

View file

@ -31,15 +31,7 @@ class XrdController < ApplicationController
end
def username_from_resource
if resource_param =~ /\Ahttps?:\/\//
path_params = Rails.application.routes.recognize_path(resource_param)
raise ActiveRecord::RecordNotFound unless path_params[:controller] == 'users' && path_params[:action] == 'show'
path_params[:username]
else
username, domain = resource_param.gsub(/\Aacct:/, '').split('@')
raise ActiveRecord::RecordNotFound unless TagManager.instance.local_domain?(domain)
username
end
WebfingerResource.new(resource_param).username
end
def pem_to_magic_key(public_key)