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:
parent
0930ce5560
commit
aa90798386
3 changed files with 155 additions and 9 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue