diaspora_federation-rails-0.0.8/0000755000004100000410000000000012604274230016661 5ustar www-datawww-datadiaspora_federation-rails-0.0.8/lib/0000755000004100000410000000000012604274230017427 5ustar www-datawww-datadiaspora_federation-rails-0.0.8/lib/diaspora_federation/0000755000004100000410000000000012604274230023431 5ustar www-datawww-datadiaspora_federation-rails-0.0.8/lib/diaspora_federation/engine.rb0000644000004100000410000000045112604274230025223 0ustar www-datawww-datamodule DiasporaFederation # diaspora* federation rails engine class Engine < ::Rails::Engine isolate_namespace DiasporaFederation config.generators do |g| g.test_framework :rspec end config.after_initialize do DiasporaFederation.validate_config end end end diaspora_federation-rails-0.0.8/lib/diaspora_federation/rails.rb0000644000004100000410000000023612604274230025071 0ustar www-datawww-datarequire "diaspora_federation/engine" require "diaspora_federation" module DiasporaFederation # diaspora* federation rails engine module Rails end end diaspora_federation-rails-0.0.8/metadata.yml0000644000004100000410000000415112604274230021165 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: diaspora_federation-rails version: !ruby/object:Gem::Version version: 0.0.8 platform: ruby authors: - Benjamin Neff autorequire: bindir: bin cert_chain: [] date: 2015-09-19 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rails requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '4.2' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '4.2' - !ruby/object:Gem::Dependency name: diaspora_federation requirement: !ruby/object:Gem::Requirement requirements: - - '=' - !ruby/object:Gem::Version version: 0.0.8 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '=' - !ruby/object:Gem::Version version: 0.0.8 description: A rails engine that adds the diaspora* federation protocol to a rails app email: - benjamin@coding4.coffee executables: [] extensions: [] extra_rdoc_files: [] files: - LICENSE - README.md - app/controllers/diaspora_federation/application_controller.rb - app/controllers/diaspora_federation/h_card_controller.rb - app/controllers/diaspora_federation/receive_controller.rb - app/controllers/diaspora_federation/webfinger_controller.rb - config/routes.rb - lib/diaspora_federation/engine.rb - lib/diaspora_federation/rails.rb homepage: https://github.com/SuperTux88/diaspora_federation licenses: - AGPL 3.0 - http://www.gnu.org/licenses/agpl-3.0.html metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '2.0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.4.6 signing_key: specification_version: 4 summary: diaspora* federation rails engine test_files: [] has_rdoc: diaspora_federation-rails-0.0.8/config/0000755000004100000410000000000012604274230020126 5ustar www-datawww-datadiaspora_federation-rails-0.0.8/config/routes.rb0000644000004100000410000000075612604274230022004 0ustar www-datawww-dataDiasporaFederation::Engine.routes.draw do controller :receive do post "receive-new/public" => :public, :as => "receive_public" post "receive-new/users/:guid" => :private, :as => "receive_private" end controller :webfinger do get ".well-known/host-meta" => :host_meta, :as => "host_meta" get "webfinger" => :legacy_webfinger, :as => "legacy_webfinger" end controller :h_card do get "hcard/users/:guid" => :hcard, :as => "hcard" end end diaspora_federation-rails-0.0.8/LICENSE0000644000004100000410000000146612604274230017675 0ustar www-datawww-dataDiaspora Federation Rails Engine Copyright (C) 2015 Benjamin Neff This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Some parts are based on an older federation gem from Florian Staudacher: https://github.com/Raven24/diaspora-federation diaspora_federation-rails-0.0.8/app/0000755000004100000410000000000012604274230017441 5ustar www-datawww-datadiaspora_federation-rails-0.0.8/app/controllers/0000755000004100000410000000000012604274230022007 5ustar www-datawww-datadiaspora_federation-rails-0.0.8/app/controllers/diaspora_federation/0000755000004100000410000000000012604274230026011 5ustar www-datawww-datadiaspora_federation-rails-0.0.8/app/controllers/diaspora_federation/receive_controller.rb0000644000004100000410000000146212604274230032226 0ustar www-datawww-datarequire_dependency "diaspora_federation/application_controller" module DiasporaFederation # this controller processes receiving messages class ReceiveController < ApplicationController before_action :check_for_xml # receives public messages # # POST /receive/public def public logger.info "received a public message" logger.debug CGI.unescape(params[:xml]) render nothing: true, status: :ok end # receives private messages for a user # # POST /receive/users/:guid def private logger.info "received a private message for #{params[:guid]}" logger.debug CGI.unescape(params[:xml]) render nothing: true, status: :ok end private def check_for_xml render nothing: true, status: 422 if params[:xml].nil? end end end diaspora_federation-rails-0.0.8/app/controllers/diaspora_federation/application_controller.rb0000644000004100000410000000022512604274230033103 0ustar www-datawww-datamodule DiasporaFederation # Base-Controller for all DiasporaFederation-Controller class ApplicationController < ActionController::Base end end diaspora_federation-rails-0.0.8/app/controllers/diaspora_federation/webfinger_controller.rb0000644000004100000410000000511512604274230032553 0ustar www-datawww-datarequire_dependency "diaspora_federation/application_controller" module DiasporaFederation # this controller handles all webfinger-specific requests class WebfingerController < ApplicationController # returns the host-meta xml # # example: # # # # # # GET /.well-known/host-meta def host_meta render body: WebfingerController.host_meta_xml, content_type: "application/xrd+xml" end # @deprecated this is the pre RFC 7033 webfinger # # example: # # # acct:alice@localhost:3000 # http://localhost:3000/people/c8e87290f6a20132963908fbffceb188 # # # # # # # # # GET /webfinger?q= def legacy_webfinger person_wf = find_person_webfinger(params[:q]) if params[:q] if person_wf.nil? render nothing: true, status: 404 else logger.info "webfinger profile request for: #{person_wf.acct_uri}" render body: person_wf.to_xml, content_type: "application/xrd+xml" end end private # creates the host-meta xml with the configured server_uri and caches it # @return [String] XML string def self.host_meta_xml @host_meta_xml ||= Discovery::HostMeta.from_base_url(DiasporaFederation.server_uri.to_s).to_xml end def find_person_webfinger(query) DiasporaFederation.callbacks.trigger(:fetch_person_for_webfinger, query.strip.downcase.sub("acct:", "")) end end end diaspora_federation-rails-0.0.8/app/controllers/diaspora_federation/h_card_controller.rb0000644000004100000410000000115212604274230032020 0ustar www-datawww-datarequire_dependency "diaspora_federation/application_controller" module DiasporaFederation # this controller generates the hcard class HCardController < ApplicationController # returns the hcard of the user # # GET /hcard/users/:guid def hcard person_hcard = DiasporaFederation.callbacks.trigger(:fetch_person_for_hcard, params[:guid]) if person_hcard.nil? render nothing: true, status: 404 else logger.info "hcard profile request for: #{person_hcard.nickname}:#{person_hcard.guid}" render html: person_hcard.to_html.html_safe end end end end diaspora_federation-rails-0.0.8/README.md0000644000004100000410000000537012604274230020145 0ustar www-datawww-data# diaspora* federation library **A library that provides functionalities needed for the diaspora* federation protocol** [![Build Status](https://travis-ci.org/SuperTux88/diaspora_federation.svg?branch=master)](https://travis-ci.org/SuperTux88/diaspora_federation) [![Code Climate](https://codeclimate.com/github/SuperTux88/diaspora_federation/badges/gpa.svg)](https://codeclimate.com/github/SuperTux88/diaspora_federation) [![Test Coverage](https://codeclimate.com/github/SuperTux88/diaspora_federation/badges/coverage.svg)](https://codeclimate.com/github/SuperTux88/diaspora_federation/coverage) [![Dependency Status](https://gemnasium.com/SuperTux88/diaspora_federation.svg)](https://gemnasium.com/SuperTux88/diaspora_federation) [![Inline docs](https://inch-ci.org/github/SuperTux88/diaspora_federation.svg?branch=master)](https://inch-ci.org/github/SuperTux88/diaspora_federation) [![Gem Version](https://badge.fury.io/rb/diaspora_federation.svg)](https://badge.fury.io/rb/diaspora_federation) [Documentation](http://www.rubydoc.info/gems/diaspora_federation/) | [Bugtracker](https://github.com/SuperTux88/diaspora_federation/issues) ## Library The ```diaspora_federation``` gem provides the functionality for de-/serialization and de-/encryption of Entities in the protocols used for communication among the various installations of Diaspora* ## Rails Engine The ```diaspora_federation-rails``` gem is a rails engine that adds the diaspora* federation protocol to a rails app. ### Usage Add the gem to your ```Gemfile```: ```ruby gem "diaspora_federation-rails" ``` Mount the routes in your ```config/routes.rb```: ```ruby mount DiasporaFederation::Engine => "/" ``` Configure the engine in ```config/initializers/diaspora_federation.rb```: ```ruby DiasporaFederation.configure do |config| # the pod url config.server_uri = AppConfig.pod_uri config.define_callbacks do on :fetch_person_for_webfinger do |diaspora_id| person = Person.find_local_by_diaspora_id(diaspora_id) if person DiasporaFederation::Discovery::WebFinger.new( # ... ) end end on :fetch_person_for_hcard do |guid| # ... end end end ``` ## Development **!!! This gem is currently under heavy development, so every release can contain breaking changes !!!** If you want to help, please contact me, help is welcome. After the first stable release, this repo will be moved to the [diaspora organization](https://github.com/diaspora/). ## Diaspora A privacy-aware, distributed, open source social network Links: [Project site](https://diasporafoundation.org) | [Wiki](https://wiki.diasporafoundation.org) ## License This gem is published under the terms of the "GNU Affero General Public License". See the LICENSE file for the exact wording.