diaspora_federation-rails 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5bf7654fe5fb9891ce35ab3724bf2f5856e78e09
4
+ data.tar.gz: a0bfe0e3755eb6c95e3040c9388130b7e63372a5
5
+ SHA512:
6
+ metadata.gz: 5c02284b47b4b559c7f3b06a54ac22f197c3cca690c6770ef53221751a143bc19dc4ea1afcc9c011f3014a64770f29107c6a6e62add69038f4a3113719626d5c
7
+ data.tar.gz: f7bb3e034736005500a5b26c9442fe5238da1772dce2f021aa976437cc09139f2bdabecead19e227add62522a1bb42d7bdfbeaec80a9499d7dbb5b7150978266
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Diaspora Federation Rails Engine
2
+ Copyright (C) 2015 Benjamin Neff
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ Some parts are based on an older federation gem from Florian Staudacher:
18
+ https://github.com/Raven24/diaspora-federation
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # diaspora* federation library
2
+
3
+ **A library that provides functionalities needed for the diaspora* federation protocol**
4
+
5
+ [![Build Status](https://travis-ci.org/SuperTux88/diaspora_federation.svg?branch=master)](https://travis-ci.org/SuperTux88/diaspora_federation)
6
+ [![Code Climate](https://codeclimate.com/github/SuperTux88/diaspora_federation/badges/gpa.svg)](https://codeclimate.com/github/SuperTux88/diaspora_federation)
7
+ [![Test Coverage](https://codeclimate.com/github/SuperTux88/diaspora_federation/badges/coverage.svg)](https://codeclimate.com/github/SuperTux88/diaspora_federation/coverage)
8
+ [![Dependency Status](https://gemnasium.com/SuperTux88/diaspora_federation.svg)](https://gemnasium.com/SuperTux88/diaspora_federation)
9
+ [![Inline docs](https://inch-ci.org/github/SuperTux88/diaspora_federation.svg?branch=master)](https://inch-ci.org/github/SuperTux88/diaspora_federation)
10
+ [![Gem Version](https://badge.fury.io/rb/diaspora_federation.svg)](https://badge.fury.io/rb/diaspora_federation)
11
+
12
+ [Documentation](http://www.rubydoc.info/gems/diaspora_federation/) |
13
+ [Bugtracker](https://github.com/SuperTux88/diaspora_federation/issues)
14
+
15
+ ## Library
16
+
17
+ The ```diaspora_federation``` gem provides the functionality for de-/serialization and de-/encryption of Entities
18
+ in the protocols used for communication among the various installations of Diaspora*
19
+
20
+ ## Rails Engine
21
+
22
+ The ```diaspora_federation-rails``` gem is a rails engine that adds the diaspora* federation protocol to a rails app.
23
+
24
+ ### Usage
25
+
26
+ Add the gem to your ```Gemfile```:
27
+
28
+ ```ruby
29
+ gem "diaspora_federation-rails"
30
+ ```
31
+
32
+ Mount the routes in your ```config/routes.rb```:
33
+
34
+ ```ruby
35
+ mount DiasporaFederation::Engine => "/"
36
+ ```
37
+
38
+ Configure the engine in ```config/initializers/diaspora_federation.rb```:
39
+
40
+ ```ruby
41
+ DiasporaFederation.configure do |config|
42
+ # the pod url
43
+ config.server_uri = AppConfig.pod_uri
44
+
45
+ # the class to be used for a person
46
+ config.person_class = Person
47
+ end
48
+ ```
49
+
50
+ ## Development
51
+
52
+ **!!! This gem is currently under heavy development, so every release can contain breaking changes !!!**
53
+
54
+ If you want to help, please contact me, help is welcome.
55
+
56
+ After the first stable release, this repo will be moved to the [diaspora organization](https://github.com/diaspora/).
57
+
58
+ ## Diaspora
59
+
60
+ A privacy-aware, distributed, open source social network
61
+
62
+ Links:
63
+ [Project site](https://diasporafoundation.org) |
64
+ [Wiki](https://wiki.diasporafoundation.org)
65
+
66
+ ## License
67
+
68
+ This gem is published under the terms of the "GNU Affero General Public License". See the LICENSE file for the exact wording.
@@ -0,0 +1,5 @@
1
+ module DiasporaFederation
2
+ # Base-Controller for all DiasporaFederation-Controller
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ require_dependency "diaspora_federation/application_controller"
2
+
3
+ module DiasporaFederation
4
+ # this controller generates the hcard
5
+ class HCardController < ApplicationController
6
+ # returns the hcard of the user
7
+ #
8
+ # GET /hcard/users/:guid
9
+ def hcard
10
+ person_hcard = DiasporaFederation.callbacks.trigger(:person_hcard_fetch, params[:guid])
11
+
12
+ return render nothing: true, status: 404 if person_hcard.nil?
13
+
14
+ logger.info "hcard profile request for: #{person_hcard.nickname}:#{person_hcard.guid}"
15
+ render html: person_hcard.to_html.html_safe
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ require_dependency "diaspora_federation/application_controller"
2
+
3
+ module DiasporaFederation
4
+ # this controller processes receiving messages
5
+ class ReceiveController < ApplicationController
6
+ before_action :check_for_xml
7
+
8
+ # receives public messages
9
+ #
10
+ # POST /receive/public
11
+ def public
12
+ logger.info "received a public message"
13
+ logger.debug CGI.unescape(params[:xml])
14
+ render nothing: true, status: :ok
15
+ end
16
+
17
+ # receives private messages for a user
18
+ #
19
+ # POST /receive/users/:guid
20
+ def private
21
+ logger.info "received a private message for #{params[:guid]}"
22
+ logger.debug CGI.unescape(params[:xml])
23
+ render nothing: true, status: :ok
24
+ end
25
+
26
+ private
27
+
28
+ def check_for_xml
29
+ render nothing: true, status: 422 if params[:xml].nil?
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,58 @@
1
+ require_dependency "diaspora_federation/application_controller"
2
+
3
+ module DiasporaFederation
4
+ # this controller handles all webfinger-specific requests
5
+ class WebfingerController < ApplicationController
6
+ # returns the host-meta xml
7
+ #
8
+ # example:
9
+ # <?xml version="1.0" encoding="UTF-8"?>
10
+ # <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
11
+ # <Link rel="lrdd" type="application/xrd+xml" template="https://server.example/webfinger?q={uri}"/>
12
+ # </XRD>
13
+ #
14
+ # GET /.well-known/host-meta
15
+ def host_meta
16
+ render body: WebfingerController.host_meta_xml, content_type: "application/xrd+xml"
17
+ end
18
+
19
+ # @deprecated this is the pre RFC 7033 webfinger
20
+ #
21
+ # example:
22
+ # <?xml version="1.0" encoding="UTF-8"?>
23
+ # <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
24
+ # <Subject>acct:alice@localhost:3000</Subject>
25
+ # <Alias>http://localhost:3000/people/c8e87290f6a20132963908fbffceb188</Alias>
26
+ # <Link rel="http://microformats.org/profile/hcard" type="text/html"
27
+ # href="http://localhost:3000/hcard/users/c8e87290f6a20132963908fbffceb188"/>
28
+ # <Link rel="http://joindiaspora.com/seed_location" type="text/html" href="http://localhost:3000/"/>
29
+ # <Link rel="http://joindiaspora.com/guid" type="text/html" href="c8e87290f6a20132963908fbffceb188"/>
30
+ # <Link rel="http://webfinger.net/rel/profile-page" type="text/html" href="http://localhost:3000/u/alice"/>
31
+ # <Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml"
32
+ # href="http://localhost:3000/public/alice.atom"/>
33
+ # <Link rel="salmon" href="http://localhost:3000/receive/users/c8e87290f6a20132963908fbffceb188"/>
34
+ # <Link rel="diaspora-public-key" type="RSA" href="LS0tLS1CRU......"/>
35
+ # </XRD>
36
+ # GET /webfinger?q=<uri>
37
+ def legacy_webfinger
38
+ person_wf = find_person_webfinger(params[:q]) if params[:q]
39
+
40
+ return render nothing: true, status: 404 if person_wf.nil?
41
+
42
+ logger.info "webfinger profile request for: #{person_wf.acct_uri}"
43
+ render body: person_wf.to_xml, content_type: "application/xrd+xml"
44
+ end
45
+
46
+ private
47
+
48
+ # creates the host-meta xml with the configured server_uri and caches it
49
+ # @return [String] XML string
50
+ def self.host_meta_xml
51
+ @host_meta_xml ||= WebFinger::HostMeta.from_base_url(DiasporaFederation.server_uri.to_s).to_xml
52
+ end
53
+
54
+ def find_person_webfinger(query)
55
+ DiasporaFederation.callbacks.trigger(:person_webfinger_fetch, query.strip.downcase.gsub("acct:", ""))
56
+ end
57
+ end
58
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,14 @@
1
+ module DiasporaFederation
2
+ # diaspora* federation rails engine
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace DiasporaFederation
5
+
6
+ config.generators do |g|
7
+ g.test_framework :rspec
8
+ end
9
+
10
+ config.after_initialize do
11
+ DiasporaFederation.validate_config
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ require "diaspora_federation/engine"
2
+
3
+ require "diaspora_federation"
4
+
5
+ module DiasporaFederation
6
+ # diaspora* federation rails engine
7
+ module Rails
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: diaspora_federation-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Benjamin Neff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: diaspora_federation
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.2
41
+ description: A rails engine that adds the diaspora* federation protocol to a rails
42
+ app
43
+ email:
44
+ - benjamin@coding4.coffee
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - LICENSE
50
+ - README.md
51
+ - app/controllers/diaspora_federation/application_controller.rb
52
+ - app/controllers/diaspora_federation/h_card_controller.rb
53
+ - app/controllers/diaspora_federation/receive_controller.rb
54
+ - app/controllers/diaspora_federation/webfinger_controller.rb
55
+ - config/routes.rb
56
+ - lib/diaspora_federation/engine.rb
57
+ - lib/diaspora_federation/rails.rb
58
+ homepage: https://github.com/SuperTux88/diaspora_federation
59
+ licenses:
60
+ - AGPL 3.0 - http://www.gnu.org/licenses/agpl-3.0.html
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '2.0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.4.6
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: diaspora* federation rails engine
82
+ test_files: []
83
+ has_rdoc: