diaspora_federation 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +55 -5
- data/lib/diaspora_federation.rb +43 -79
- data/lib/diaspora_federation/callbacks.rb +62 -0
- data/lib/diaspora_federation/entity.rb +146 -0
- data/lib/diaspora_federation/logging.rb +3 -4
- data/lib/diaspora_federation/properties_dsl.rb +106 -0
- data/lib/diaspora_federation/version.rb +1 -2
- data/lib/diaspora_federation/web_finger.rb +0 -1
- data/lib/diaspora_federation/web_finger/exceptions.rb +1 -5
- data/lib/diaspora_federation/web_finger/h_card.rb +101 -127
- data/lib/diaspora_federation/web_finger/host_meta.rb +0 -7
- data/lib/diaspora_federation/web_finger/web_finger.rb +79 -110
- data/lib/diaspora_federation/web_finger/xrd_document.rb +0 -3
- data/lib/tasks/build.rake +17 -0
- metadata +20 -30
- data/Rakefile +0 -26
- data/app/controllers/diaspora_federation/application_controller.rb +0 -6
- data/app/controllers/diaspora_federation/h_card_controller.rb +0 -20
- data/app/controllers/diaspora_federation/receive_controller.rb +0 -35
- data/app/controllers/diaspora_federation/webfinger_controller.rb +0 -60
- data/config/routes.rb +0 -15
- data/lib/diaspora_federation/engine.rb +0 -15
@@ -1,20 +0,0 @@
|
|
1
|
-
require_dependency "diaspora_federation/application_controller"
|
2
|
-
|
3
|
-
module DiasporaFederation
|
4
|
-
##
|
5
|
-
# this controller generates the hcard
|
6
|
-
class HCardController < ApplicationController
|
7
|
-
##
|
8
|
-
# returns the hcard of the user
|
9
|
-
#
|
10
|
-
# GET /hcard/users/:guid
|
11
|
-
def hcard
|
12
|
-
person = DiasporaFederation.person_class.find_local_by_guid(params[:guid])
|
13
|
-
|
14
|
-
return render nothing: true, status: 404 if person.nil?
|
15
|
-
|
16
|
-
logger.info "hcard profile request for: #{person.diaspora_handle}"
|
17
|
-
render html: WebFinger::HCard.from_profile(person.hcard_profile_hash).to_html.html_safe
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require_dependency "diaspora_federation/application_controller"
|
2
|
-
|
3
|
-
module DiasporaFederation
|
4
|
-
##
|
5
|
-
# this controller processes receiving messages
|
6
|
-
class ReceiveController < ApplicationController
|
7
|
-
before_action :check_for_xml
|
8
|
-
|
9
|
-
##
|
10
|
-
# receives public messages
|
11
|
-
#
|
12
|
-
# POST /receive/public
|
13
|
-
def public
|
14
|
-
logger.info "received a public message"
|
15
|
-
logger.debug CGI.unescape(params[:xml])
|
16
|
-
render nothing: true, status: :ok
|
17
|
-
end
|
18
|
-
|
19
|
-
##
|
20
|
-
# receives private messages for a user
|
21
|
-
#
|
22
|
-
# POST /receive/users/:guid
|
23
|
-
def private
|
24
|
-
logger.info "received a private message for #{params[:guid]}"
|
25
|
-
logger.debug CGI.unescape(params[:xml])
|
26
|
-
render nothing: true, status: :ok
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def check_for_xml
|
32
|
-
render nothing: true, status: 422 if params[:xml].nil?
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require_dependency "diaspora_federation/application_controller"
|
2
|
-
|
3
|
-
module DiasporaFederation
|
4
|
-
##
|
5
|
-
# this controller handles all webfinger-specific requests
|
6
|
-
class WebfingerController < ApplicationController
|
7
|
-
##
|
8
|
-
# returns the host-meta xml
|
9
|
-
#
|
10
|
-
# example:
|
11
|
-
# <?xml version="1.0" encoding="UTF-8"?>
|
12
|
-
# <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
13
|
-
# <Link rel="lrdd" type="application/xrd+xml" template="https://server.example/webfinger?q={uri}"/>
|
14
|
-
# </XRD>
|
15
|
-
#
|
16
|
-
# GET /.well-known/host-meta
|
17
|
-
def host_meta
|
18
|
-
render body: WebfingerController.host_meta_xml, content_type: "application/xrd+xml"
|
19
|
-
end
|
20
|
-
|
21
|
-
##
|
22
|
-
# @deprecated this is the pre RFC 7033 webfinger
|
23
|
-
#
|
24
|
-
# example:
|
25
|
-
# <?xml version="1.0" encoding="UTF-8"?>
|
26
|
-
# <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
27
|
-
# <Subject>acct:alice@localhost:3000</Subject>
|
28
|
-
# <Alias>http://localhost:3000/people/c8e87290f6a20132963908fbffceb188</Alias>
|
29
|
-
# <Link rel="http://microformats.org/profile/hcard" type="text/html" href="http://localhost:3000/hcard/users/c8e87290f6a20132963908fbffceb188"/>
|
30
|
-
# <Link rel="http://joindiaspora.com/seed_location" type="text/html" href="http://localhost:3000/"/>
|
31
|
-
# <Link rel="http://joindiaspora.com/guid" type="text/html" href="c8e87290f6a20132963908fbffceb188"/>
|
32
|
-
# <Link rel="http://webfinger.net/rel/profile-page" type="text/html" href="http://localhost:3000/u/alice"/>
|
33
|
-
# <Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="http://localhost:3000/public/alice.atom"/>
|
34
|
-
# <Link rel="salmon" href="http://localhost:3000/receive/users/c8e87290f6a20132963908fbffceb188"/>
|
35
|
-
# <Link rel="diaspora-public-key" type="RSA" href="LS0tLS1CRU......"/>
|
36
|
-
# </XRD>
|
37
|
-
# GET /webfinger?q=<uri>
|
38
|
-
def legacy_webfinger
|
39
|
-
person = find_person(params[:q]) if params[:q]
|
40
|
-
|
41
|
-
return render nothing: true, status: 404 if person.nil?
|
42
|
-
|
43
|
-
logger.info "webfinger profile request for: #{person.diaspora_handle}"
|
44
|
-
render body: WebFinger::WebFinger.from_person(person.webfinger_hash).to_xml, content_type: "application/xrd+xml"
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
##
|
50
|
-
# creates the host-meta xml with the configured server_uri and caches it
|
51
|
-
# @return [String] XML string
|
52
|
-
def self.host_meta_xml
|
53
|
-
@host_meta_xml ||= WebFinger::HostMeta.from_base_url(DiasporaFederation.server_uri.to_s).to_xml
|
54
|
-
end
|
55
|
-
|
56
|
-
def find_person(query)
|
57
|
-
DiasporaFederation.person_class.find_local_by_diaspora_handle(query.strip.downcase.gsub("acct:", ""))
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
data/config/routes.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
DiasporaFederation::Engine.routes.draw do
|
2
|
-
controller :receive do
|
3
|
-
post "receive-new/public" => :public, :as => "receive_public"
|
4
|
-
post "receive-new/users/:guid" => :private, :as => "receive_private"
|
5
|
-
end
|
6
|
-
|
7
|
-
controller :webfinger do
|
8
|
-
get ".well-known/host-meta" => :host_meta, :as => "host_meta"
|
9
|
-
get "webfinger" => :legacy_webfinger, :as => "legacy_webfinger"
|
10
|
-
end
|
11
|
-
|
12
|
-
controller :h_card do
|
13
|
-
get "hcard/users/:guid" => :hcard, :as => "hcard"
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module DiasporaFederation
|
2
|
-
##
|
3
|
-
# diaspora* federation rails engine
|
4
|
-
class Engine < ::Rails::Engine
|
5
|
-
isolate_namespace DiasporaFederation
|
6
|
-
|
7
|
-
config.generators do |g|
|
8
|
-
g.test_framework :rspec
|
9
|
-
end
|
10
|
-
|
11
|
-
config.after_initialize do
|
12
|
-
DiasporaFederation.validate_config
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|