Compare commits
1 commit
activitypu
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
|
0144c90292 |
4 changed files with 22 additions and 72 deletions
21
Gemfile.lock
21
Gemfile.lock
|
@ -105,6 +105,7 @@ GEM
|
||||||
aws-sigv4 (~> 1.4)
|
aws-sigv4 (~> 1.4)
|
||||||
aws-sigv4 (1.5.2)
|
aws-sigv4 (1.5.2)
|
||||||
aws-eventstream (~> 1, >= 1.0.2)
|
aws-eventstream (~> 1, >= 1.0.2)
|
||||||
|
base64 (0.1.1)
|
||||||
bcrypt (3.1.17)
|
bcrypt (3.1.17)
|
||||||
better_errors (2.9.1)
|
better_errors (2.9.1)
|
||||||
coderay (>= 1.0.0)
|
coderay (>= 1.0.0)
|
||||||
|
@ -367,6 +368,7 @@ GEM
|
||||||
marcel (~> 1.0.1)
|
marcel (~> 1.0.1)
|
||||||
mime-types
|
mime-types
|
||||||
terrapin (~> 0.6.0)
|
terrapin (~> 0.6.0)
|
||||||
|
language_server-protocol (3.17.0.3)
|
||||||
launchy (2.5.0)
|
launchy (2.5.0)
|
||||||
addressable (~> 2.7)
|
addressable (~> 2.7)
|
||||||
letter_opener (1.8.1)
|
letter_opener (1.8.1)
|
||||||
|
@ -462,9 +464,10 @@ GEM
|
||||||
openssl (> 2.0, < 3.1)
|
openssl (> 2.0, < 3.1)
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
ox (2.14.14)
|
ox (2.14.14)
|
||||||
parallel (1.22.1)
|
parallel (1.23.0)
|
||||||
parser (3.2.0.0)
|
parser (3.2.2.3)
|
||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
|
racc
|
||||||
parslet (2.0.0)
|
parslet (2.0.0)
|
||||||
pastel (0.8.0)
|
pastel (0.8.0)
|
||||||
tty-color (~> 0.5)
|
tty-color (~> 0.5)
|
||||||
|
@ -560,7 +563,7 @@ GEM
|
||||||
redis (>= 4)
|
redis (>= 4)
|
||||||
redlock (1.3.2)
|
redlock (1.3.2)
|
||||||
redis (>= 3.0.0, < 6.0)
|
redis (>= 3.0.0, < 6.0)
|
||||||
regexp_parser (2.6.2)
|
regexp_parser (2.8.1)
|
||||||
request_store (1.5.1)
|
request_store (1.5.1)
|
||||||
rack (>= 1.4)
|
rack (>= 1.4)
|
||||||
responders (3.0.1)
|
responders (3.0.1)
|
||||||
|
@ -595,18 +598,20 @@ GEM
|
||||||
rspec-support (3.11.1)
|
rspec-support (3.11.1)
|
||||||
rspec_junit_formatter (0.6.0)
|
rspec_junit_formatter (0.6.0)
|
||||||
rspec-core (>= 2, < 4, != 2.12.0)
|
rspec-core (>= 2, < 4, != 2.12.0)
|
||||||
rubocop (1.44.1)
|
rubocop (1.56.0)
|
||||||
|
base64 (~> 0.1.1)
|
||||||
json (~> 2.3)
|
json (~> 2.3)
|
||||||
|
language_server-protocol (>= 3.17.0)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
parser (>= 3.2.0.0)
|
parser (>= 3.2.2.3)
|
||||||
rainbow (>= 2.2.2, < 4.0)
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
regexp_parser (>= 1.8, < 3.0)
|
regexp_parser (>= 1.8, < 3.0)
|
||||||
rexml (>= 3.2.5, < 4.0)
|
rexml (>= 3.2.5, < 4.0)
|
||||||
rubocop-ast (>= 1.24.1, < 2.0)
|
rubocop-ast (>= 1.28.1, < 2.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (>= 2.4.0, < 3.0)
|
unicode-display_width (>= 2.4.0, < 3.0)
|
||||||
rubocop-ast (1.24.1)
|
rubocop-ast (1.29.0)
|
||||||
parser (>= 3.1.1.0)
|
parser (>= 3.2.1.0)
|
||||||
rubocop-capybara (2.17.0)
|
rubocop-capybara (2.17.0)
|
||||||
rubocop (~> 1.41)
|
rubocop (~> 1.41)
|
||||||
rubocop-performance (1.16.0)
|
rubocop-performance (1.16.0)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "faraday"
|
require "faraday"
|
||||||
require "uri"
|
|
||||||
|
|
||||||
class Api::V1::JsonLdController < Api::BaseController
|
class Api::V1::JsonLdController < Api::BaseController
|
||||||
include ActionController::Live
|
include ActionController::Live
|
||||||
|
@ -10,40 +9,6 @@ class Api::V1::JsonLdController < Api::BaseController
|
||||||
render json: { error: e.to_s }, status: 422
|
render json: { error: e.to_s }, status: 422
|
||||||
end
|
end
|
||||||
|
|
||||||
before_action :require_user!
|
|
||||||
|
|
||||||
REQUEST_TARGET = '(request-target)'
|
|
||||||
|
|
||||||
def signature(headers)
|
|
||||||
account = Account.representative
|
|
||||||
|
|
||||||
key_id = ActivityPub::TagManager.instance.key_uri_for(account)
|
|
||||||
algorithm = 'rsa-sha256'
|
|
||||||
signed_string = headers.map { |key, value| "#{key.downcase}: #{value}" }.join("\n")
|
|
||||||
signature = Base64.strict_encode64(account.keypair.sign(OpenSSL::Digest.new('SHA256'), signed_string))
|
|
||||||
|
|
||||||
"keyId=\"#{key_id}\",algorithm=\"#{algorithm}\",headers=\"#{headers.keys.join(' ').downcase}\",signature=\"#{signature}\""
|
|
||||||
end
|
|
||||||
|
|
||||||
def signed_headers(url_string)
|
|
||||||
if url_string.include?(".well-known")
|
|
||||||
return {'Accept': 'application/jrd+json'}
|
|
||||||
end
|
|
||||||
|
|
||||||
url = URI.parse(url_string)
|
|
||||||
tmp_headers = {
|
|
||||||
'Date': Time.now.utc.httpdate,
|
|
||||||
'Host': url.host,
|
|
||||||
'Accept': 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
|
||||||
}
|
|
||||||
tmp_headers[REQUEST_TARGET] = "get #{url_string.delete_prefix("#{url.scheme}://#{url.host}")}"
|
|
||||||
additional_headers = {
|
|
||||||
'Signature': signature(tmp_headers),
|
|
||||||
'User-Agent': Mastodon::Version.user_agent,
|
|
||||||
}
|
|
||||||
tmp_headers.merge(additional_headers).except(REQUEST_TARGET)
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
url = params[:url]
|
url = params[:url]
|
||||||
|
|
||||||
|
@ -52,12 +17,13 @@ class Api::V1::JsonLdController < Api::BaseController
|
||||||
Thread.new {
|
Thread.new {
|
||||||
begin
|
begin
|
||||||
conn = Faraday::Connection.new
|
conn = Faraday::Connection.new
|
||||||
|
conn.options.timeout = 5
|
||||||
|
|
||||||
api_response = conn.get(url, nil, signed_headers(url))
|
api_response = conn.get(url, nil, {'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'})
|
||||||
|
|
||||||
max_redirects = 5
|
max_redirects = 5
|
||||||
while api_response.status == 301 || api_response.status == 302 and max_redirects > 0 do
|
while api_response.status == 301 || api_response.status == 302 and max_redirects > 0 do
|
||||||
api_response = conn.get(api_response.headers['Location'], nil, signed_headers(api_response.headers['Location']))
|
api_response = conn.get(api_response.headers['Location'], nil, {'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'})
|
||||||
max_redirects -= 1
|
max_redirects -= 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
- thumbnail = @instance_presenter.thumbnail
|
- thumbnail = @instance_presenter.thumbnail
|
||||||
- description = 'Learn ActivityPub interactively, by seeing protocol interactions visualized in real time'
|
- description ||= @instance_presenter.description.presence || strip_tags(t('about.about_mastodon_html'))
|
||||||
|
|
||||||
%meta{ name: 'description', content: description }/
|
%meta{ name: 'description', content: description }/
|
||||||
|
|
||||||
= opengraph 'og:site_name', 'ActivityPub Academy - A learning resource for ActivityPub'
|
= opengraph 'og:site_name', t('about.hosted_on', domain: site_hostname)
|
||||||
= opengraph 'og:url', url_for(only_path: false)
|
= opengraph 'og:url', url_for(only_path: false)
|
||||||
= opengraph 'og:type', 'website'
|
= opengraph 'og:type', 'website'
|
||||||
= opengraph 'og:title', 'ActivityPub Academy'
|
= opengraph 'og:title', @instance_presenter.title
|
||||||
= opengraph 'og:description', description
|
= opengraph 'og:description', description
|
||||||
= opengraph 'og:image', full_asset_url(thumbnail&.file&.url(:'@1x') || asset_pack_path('media/images/academy-mascot.webp', protocol: :request))
|
= opengraph 'og:image', full_asset_url(thumbnail&.file&.url(:'@1x') || asset_pack_path('media/images/preview.png', protocol: :request))
|
||||||
= opengraph 'og:image:width', thumbnail ? thumbnail.meta['width'] : '500'
|
= opengraph 'og:image:width', thumbnail ? thumbnail.meta['width'] : '1200'
|
||||||
= opengraph 'og:image:height', thumbnail ? thumbnail.meta['height'] : '573'
|
= opengraph 'og:image:height', thumbnail ? thumbnail.meta['height'] : '630'
|
||||||
= opengraph 'twitter:card', 'summary_large_image'
|
= opengraph 'twitter:card', 'summary_large_image'
|
||||||
|
|
21
dist/nginx.conf
vendored
21
dist/nginx.conf
vendored
|
@ -114,27 +114,6 @@ server {
|
||||||
tcp_nodelay on;
|
tcp_nodelay on;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ^~ /api/v1/json_ld {
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto https;
|
|
||||||
proxy_set_header Proxy "";
|
|
||||||
proxy_pass_header Server;
|
|
||||||
|
|
||||||
proxy_pass http://backend;
|
|
||||||
proxy_redirect off;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection '';
|
|
||||||
|
|
||||||
proxy_cache off;
|
|
||||||
proxy_buffering off;
|
|
||||||
chunked_transfer_encoding off;
|
|
||||||
|
|
||||||
tcp_nodelay on;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ^~ /api/v1/activity_log {
|
location ^~ /api/v1/activity_log {
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
|
Loading…
Add table
Reference in a new issue