diaspora_federation-rails 0.2.8 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ec3f1dc1e66c06c1f8d58211245bc1bcec268f85ab5d40d18a36d374d7da2c9
4
- data.tar.gz: 2aff34f8579c46f20f0bc1b94ff78ee36236199e5e819587ecb51f2d540cfa80
3
+ metadata.gz: 0444b72a3eeb931128d632cb0777a6bf794a8edf5dc7779bef48f5938c60aef7
4
+ data.tar.gz: c23ac4c79c153a1bd494c5b60da433c4d9dbec86043b6e7f137e8c723b6c00db
5
5
  SHA512:
6
- metadata.gz: 7aaf397d67ca55c5ad18d1d51a8bf1c0051aad13982e6682a4081d741eadebb384f623ef01c487b05b02361a72c1ad9bb5e71b1ea3707a5237df672e8f7916f6
7
- data.tar.gz: e6555bcc78f546d58846d654be703e517418a56008f237bc36705f93509ef4035534b7dfc2f701d50e1d45db890f06a8d4cb3b1560bdacfbebb0b33ae56d3a5c
6
+ metadata.gz: dda5acc72f0716f6d2761b5089d683c88cfcc411c16d90b62d8fd43ea19f8f184be60e48729664949b21ad7d4dd38629ffc49c5ad29bdf1f4896c2b0d4cdc0de
7
+ data.tar.gz: 8c9de5b73af8ec975711a5e460b145df6f8273bb1c743583e3205c31adb4043dd6abe8a3d6af0a8f66f831295202e71fc6133fe68dd6e8f8d2086e16a84aa907
data/Changelog.md CHANGED
@@ -1,3 +1,28 @@
1
+ # 1.0.1
2
+
3
+ * Disable rails forgery protection for the federation controller by default [#127](https://github.com/diaspora/diaspora_federation/pull/127)
4
+
5
+ # 1.0.0
6
+
7
+ * Add rails 7 support [#126](https://github.com/diaspora/diaspora_federation/pull/126)
8
+ * Add faraday 2 support [#126](https://github.com/diaspora/diaspora_federation/pull/126)
9
+
10
+ # 0.3.0
11
+
12
+ ## Breaking changes
13
+
14
+ * Drop support for rails 5.1 and older [4b4375c](https://github.com/diaspora/diaspora_federation/commit/4b4375cf787e09537f53aff92b054a0386681747) [ecfe0ea](https://github.com/diaspora/diaspora_federation/commit/ecfe0ea850d203e8144adab744c4b43263200902)
15
+ * Drop support for ruby 2.6 and older [68df3cf](https://github.com/diaspora/diaspora_federation/commit/68df3cf555efafc72942cfec2c8fb3e8852ddec1) [#121](https://github.com/diaspora/diaspora_federation/pull/121)
16
+ * Drop support for faraday 0.x [#116](https://github.com/diaspora/diaspora_federation/pull/116)
17
+ * Remove support to receive old federation protocol [#114](https://github.com/diaspora/diaspora_federation/pull/114)
18
+ * Remove support for old non-RFC WebFinger [#122](https://github.com/diaspora/diaspora_federation/pull/122)
19
+
20
+ ## Features
21
+
22
+ * Add rails 6 support [afee784](https://github.com/diaspora/diaspora_federation/commit/afee78476b1715ba32e2b97d7cbf2584d57718dd)
23
+ * Add faraday 1.x support [#116](https://github.com/diaspora/diaspora_federation/pull/116)
24
+ * Add support for up to ruby 3.1 [#121](https://github.com/diaspora/diaspora_federation/pull/121)
25
+
1
26
  # 0.2.8
2
27
 
3
28
  * Re-release which allows rails 6 to be used
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DiasporaFederation
2
4
  # Base controller for all DiasporaFederation controllers
3
5
  class ApplicationController < ActionController::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_dependency "diaspora_federation/application_controller"
2
4
 
3
5
  module DiasporaFederation
@@ -13,8 +15,9 @@ module DiasporaFederation
13
15
  if magic_env
14
16
  render xml: magic_env, content_type: "application/magic-envelope+xml"
15
17
  else
16
- redirect_to DiasporaFederation.callbacks.trigger(:fetch_person_url_to,
17
- entity.author, "/fetch/#{params[:type]}/#{params[:guid]}")
18
+ redirect_url = DiasporaFederation.callbacks.trigger(:fetch_person_url_to,
19
+ entity.author, "/fetch/#{params[:type]}/#{params[:guid]}")
20
+ redirect_to redirect_url, allow_other_host: true
18
21
  end
19
22
  else
20
23
  head :not_found
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_dependency "diaspora_federation/application_controller"
2
4
 
3
5
  module DiasporaFederation
@@ -1,20 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_dependency "diaspora_federation/application_controller"
2
4
 
3
5
  module DiasporaFederation
4
6
  # This controller processes receiving messages.
5
7
  class ReceiveController < ApplicationController
6
- before_action :check_for_xml
8
+ skip_forgery_protection
7
9
 
8
10
  # Receives public messages
9
11
  #
10
12
  # POST /receive/public
11
13
  def public
12
- legacy = request.content_type != "application/magic-envelope+xml"
13
-
14
- data = data_for_public_message(legacy)
14
+ data = request.body.read
15
15
  logger.debug data
16
16
 
17
- DiasporaFederation.callbacks.trigger(:queue_public_receive, data, legacy)
17
+ DiasporaFederation.callbacks.trigger(:queue_public_receive, data)
18
18
 
19
19
  head :accepted
20
20
  end
@@ -23,43 +23,12 @@ module DiasporaFederation
23
23
  #
24
24
  # POST /receive/users/:guid
25
25
  def private
26
- legacy = request.content_type != "application/json"
27
-
28
- data = data_for_private_message(legacy)
26
+ data = request.body.read
29
27
  logger.debug data
30
28
 
31
- success = DiasporaFederation.callbacks.trigger(:queue_private_receive, params[:guid], data, legacy)
29
+ success = DiasporaFederation.callbacks.trigger(:queue_private_receive, params[:guid], data)
32
30
 
33
31
  head success ? :accepted : :not_found
34
32
  end
35
-
36
- private
37
-
38
- # Checks the xml parameter for legacy salmon slaps
39
- # @deprecated
40
- def check_for_xml
41
- legacy_request = request.content_type.nil? || request.content_type == "application/x-www-form-urlencoded"
42
- head :unprocessable_entity if params[:xml].nil? && legacy_request
43
- end
44
-
45
- def data_for_public_message(legacy)
46
- if legacy
47
- logger.info "received a public salmon slap"
48
- CGI.unescape(params[:xml])
49
- else
50
- logger.info "received a public magic envelope"
51
- request.body.read
52
- end
53
- end
54
-
55
- def data_for_private_message(legacy)
56
- if legacy
57
- logger.info "received a private salmon slap for #{params[:guid]}"
58
- CGI.unescape(params[:xml])
59
- else
60
- logger.info "received a private encrypted magic envelope for #{params[:guid]}"
61
- request.body.read
62
- end
63
- end
64
33
  end
65
34
  end
@@ -1,22 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_dependency "diaspora_federation/application_controller"
2
4
 
3
5
  module DiasporaFederation
4
6
  # This controller handles all webfinger-specific requests.
5
7
  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"
12
- # template="https://server.example/.well-known/webfinger.xml?resource={uri}"/>
13
- # </XRD>
14
- #
15
- # GET /.well-known/host-meta
16
- def host_meta
17
- render xml: WebfingerController.host_meta_xml, content_type: "application/xrd+xml"
18
- end
19
-
20
8
  # Returns the webfinger as RFC 7033 JRD or XRD.
21
9
  #
22
10
  # JSON example:
@@ -57,20 +45,6 @@ module DiasporaFederation
57
45
  # ]
58
46
  # }
59
47
  #
60
- # XML example:
61
- # <?xml version="1.0" encoding="UTF-8"?>
62
- # <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
63
- # <Subject>acct:alice@localhost:3000</Subject>
64
- # <Alias>http://localhost:3000/people/c8e87290f6a20132963908fbffceb188</Alias>
65
- # <Link rel="http://microformats.org/profile/hcard" type="text/html"
66
- # href="http://localhost:3000/hcard/users/c8e87290f6a20132963908fbffceb188"/>
67
- # <Link rel="http://joindiaspora.com/seed_location" type="text/html" href="http://localhost:3000/"/>
68
- # <Link rel="http://webfinger.net/rel/profile-page" type="text/html" href="http://localhost:3000/u/alice"/>
69
- # <Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml"
70
- # href="http://localhost:3000/public/alice.atom"/>
71
- # <Link rel="salmon" href="http://localhost:3000/receive/users/c8e87290f6a20132963908fbffceb188"/>
72
- # </XRD>
73
- #
74
48
  # GET /.well-known/webfinger?resource=<uri>
75
49
  def webfinger
76
50
  person_wf = find_person_webfinger(params.require(:resource))
@@ -78,26 +52,13 @@ module DiasporaFederation
78
52
  if person_wf.nil?
79
53
  head :not_found
80
54
  else
81
- logger.info "webfinger profile request for: #{person_wf.acct_uri}"
55
+ logger.info "Webfinger profile request for: #{person_wf.acct_uri}"
82
56
 
83
- respond_to do |format|
84
- format.any(:jrd, :json, :html) do
85
- headers["Access-Control-Allow-Origin"] = "*"
86
- render json: JSON.pretty_generate(person_wf.to_json), content_type: "application/jrd+json"
87
- end
88
- format.any(:xrd, :xml) do
89
- render xml: person_wf.to_xml, content_type: "application/xrd+xml"
90
- end
91
- end
57
+ headers["Access-Control-Allow-Origin"] = "*"
58
+ render json: JSON.pretty_generate(person_wf.to_json), content_type: "application/jrd+json"
92
59
  end
93
60
  end
94
61
 
95
- # Creates the host-meta xml with the configured server_uri and caches it
96
- # @return [String] XML string
97
- def self.host_meta_xml
98
- @host_meta_xml ||= Discovery::HostMeta.from_base_url(DiasporaFederation.server_uri.to_s).to_xml
99
- end
100
-
101
62
  private
102
63
 
103
64
  def find_person_webfinger(query)
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Don't log received xml data.
2
4
  Rails.application.config.filter_parameters += %i[xml aes_key encrypted_magic_envelope]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # mime types for webfinger
2
4
  Mime::Type.register "application/jrd+json", :jrd
3
5
  Mime::Type.register "application/xrd+xml", :xrd
data/config/routes.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  DiasporaFederation::Engine.routes.draw do
2
4
  controller :receive do
3
5
  post "receive/public" => :public, :as => "receive_public"
@@ -9,7 +11,6 @@ DiasporaFederation::Engine.routes.draw do
9
11
  end
10
12
 
11
13
  controller :webfinger do
12
- get ".well-known/host-meta" => :host_meta, :as => "host_meta"
13
14
  get ".well-known/webfinger" => :webfinger, :as => "webfinger"
14
15
  end
15
16
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DiasporaFederation
2
4
  # diaspora* federation rails engine
3
5
  class Engine < ::Rails::Engine
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "diaspora_federation/engine"
2
4
 
3
5
  require "diaspora_federation"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diaspora_federation-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Neff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-17 00:00:00.000000000 Z
11
+ date: 2022-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -16,34 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: '5.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '8'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '4.2'
29
+ version: '5.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '8'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: diaspora_federation
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 0.2.8
39
+ version: 1.0.1
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - '='
45
45
  - !ruby/object:Gem::Version
46
- version: 0.2.8
46
+ version: 1.0.1
47
47
  description: A rails engine that adds the diaspora* federation protocol to a rails
48
48
  app
49
49
  email:
@@ -76,16 +76,16 @@ require_paths:
76
76
  - lib
77
77
  required_ruby_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: '2.1'
81
+ version: '2.7'
82
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  requirements:
84
84
  - - ">="
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
- rubygems_version: 3.0.9
88
+ rubygems_version: 3.3.7
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: diaspora* federation rails engine