diaspora_federation-rails 0.2.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: def5768f427561712f90dde409852e24db9a3574d87bd54159d0cdff62c61cc2
4
- data.tar.gz: 7be5012aa9576fdbcdfdf3c8343470dca33cc6ee38b0d9c3907dd2b7324b9f99
3
+ metadata.gz: 24c43f3bd8177934e5fa2846e729af05097619324c2cde30c76c44f564a2b993
4
+ data.tar.gz: c6143bd562b8a837f507af43c7cb00a99bd0c36253258811f414ddacfc238146
5
5
  SHA512:
6
- metadata.gz: 2a26adfdb0e67124a0ffb50b5f1a784c65282f10b84299412708666b2667d8ae388fc0ac992cd09a5019c1511bf7191c22c36aab8e1f83e1cf87f44dac0aab71
7
- data.tar.gz: d27249d08c5de364cee256e38cd35c711cc64b6c6db198aae09135b63ca856ef76baa7a467aa55db6304c9b6255b2e9fc9009ad4a8e354ab0163103b0315aa3f
6
+ metadata.gz: 8d690d9146fe8d665d6865d1632a7463f261029db309829b882d2d18762ccf3aa116a224fe41df50de481a55df37f2b3bc4050015aedbc08d746e96ac7473271
7
+ data.tar.gz: 7e80839194400460b894e69726a82c5cd0ff5dd08a997955ff6d49d08edc0a5c9bcfd3297e1fbe65628c22eeb964bb5e6a98ec4e7e88c9e44271c883b4ec8277
data/Changelog.md CHANGED
@@ -1,3 +1,28 @@
1
+ # 1.0.0
2
+
3
+ * Add rails 7 support [#126](https://github.com/diaspora/diaspora_federation/pull/126)
4
+ * Add faraday 2 support [#126](https://github.com/diaspora/diaspora_federation/pull/126)
5
+
6
+ # 0.3.0
7
+
8
+ ## Breaking changes
9
+
10
+ * 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)
11
+ * 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)
12
+ * Drop support for faraday 0.x [#116](https://github.com/diaspora/diaspora_federation/pull/116)
13
+ * Remove support to receive old federation protocol [#114](https://github.com/diaspora/diaspora_federation/pull/114)
14
+ * Remove support for old non-RFC WebFinger [#122](https://github.com/diaspora/diaspora_federation/pull/122)
15
+
16
+ ## Features
17
+
18
+ * Add rails 6 support [afee784](https://github.com/diaspora/diaspora_federation/commit/afee78476b1715ba32e2b97d7cbf2584d57718dd)
19
+ * Add faraday 1.x support [#116](https://github.com/diaspora/diaspora_federation/pull/116)
20
+ * Add support for up to ruby 3.1 [#121](https://github.com/diaspora/diaspora_federation/pull/121)
21
+
22
+ # 0.2.8
23
+
24
+ * Re-release which allows rails 6 to be used
25
+
1
26
  # 0.2.7
2
27
 
3
28
  ## Features
@@ -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,18 @@
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
7
-
8
8
  # Receives public messages
9
9
  #
10
10
  # POST /receive/public
11
11
  def public
12
- legacy = request.content_type != "application/magic-envelope+xml"
13
-
14
- data = data_for_public_message(legacy)
12
+ data = request.body.read
15
13
  logger.debug data
16
14
 
17
- DiasporaFederation.callbacks.trigger(:queue_public_receive, data, legacy)
15
+ DiasporaFederation.callbacks.trigger(:queue_public_receive, data)
18
16
 
19
17
  head :accepted
20
18
  end
@@ -23,43 +21,12 @@ module DiasporaFederation
23
21
  #
24
22
  # POST /receive/users/:guid
25
23
  def private
26
- legacy = request.content_type != "application/json"
27
-
28
- data = data_for_private_message(legacy)
24
+ data = request.body.read
29
25
  logger.debug data
30
26
 
31
- success = DiasporaFederation.callbacks.trigger(:queue_private_receive, params[:guid], data, legacy)
27
+ success = DiasporaFederation.callbacks.trigger(:queue_private_receive, params[:guid], data)
32
28
 
33
29
  head success ? :accepted : :not_found
34
30
  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
31
  end
65
32
  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.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Neff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-24 00:00:00.000000000 Z
11
+ date: 2022-07-18 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: '6'
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: '6'
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.7
39
+ version: 1.0.0
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.7
46
+ version: 1.0.0
47
47
  description: A rails engine that adds the diaspora* federation protocol to a rails
48
48
  app
49
49
  email:
@@ -68,23 +68,24 @@ files:
68
68
  homepage: https://github.com/diaspora/diaspora_federation
69
69
  licenses:
70
70
  - AGPL-3.0
71
- metadata: {}
71
+ metadata:
72
+ rubygems_mfa_required: 'true'
72
73
  post_install_message:
73
74
  rdoc_options: []
74
75
  require_paths:
75
76
  - lib
76
77
  required_ruby_version: !ruby/object:Gem::Requirement
77
78
  requirements:
78
- - - "~>"
79
+ - - ">="
79
80
  - !ruby/object:Gem::Version
80
- version: '2.1'
81
+ version: '2.7'
81
82
  required_rubygems_version: !ruby/object:Gem::Requirement
82
83
  requirements:
83
84
  - - ">="
84
85
  - !ruby/object:Gem::Version
85
86
  version: '0'
86
87
  requirements: []
87
- rubygems_version: 3.0.9
88
+ rubygems_version: 3.3.7
88
89
  signing_key:
89
90
  specification_version: 4
90
91
  summary: diaspora* federation rails engine