2016-11-28 23:36:47 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-02-14 23:12:13 +11:00
|
|
|
require 'sidekiq_unique_jobs/web' if ENV['ENABLE_SIDEKIQ_UNIQUE_JOBS_UI'] == true
|
2017-05-08 11:52:57 +10:00
|
|
|
require 'sidekiq-scheduler/web'
|
2016-03-25 12:50:48 +11:00
|
|
|
|
2023-11-08 21:31:05 +11:00
|
|
|
class RedirectWithVary < ActionDispatch::Routing::PathRedirect
|
|
|
|
def build_response(req)
|
|
|
|
super.tap do |response|
|
|
|
|
response.headers['Vary'] = 'Origin, Accept'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def redirect_with_vary(path)
|
|
|
|
RedirectWithVary.new(301, path)
|
|
|
|
end
|
|
|
|
|
2016-02-21 08:53:20 +11:00
|
|
|
Rails.application.routes.draw do
|
2022-10-26 23:01:02 +11:00
|
|
|
# Paths of routes on the web app that to not require to be indexed or
|
|
|
|
# have alternative format representations requiring separate controllers
|
|
|
|
web_app_paths = %w(
|
|
|
|
/getting-started
|
|
|
|
/keyboard-shortcuts
|
|
|
|
/home
|
|
|
|
/public
|
|
|
|
/public/local
|
2023-07-04 06:57:18 +10:00
|
|
|
/public/remote
|
2022-10-26 23:01:02 +11:00
|
|
|
/conversations
|
|
|
|
/lists/(*any)
|
2024-07-02 00:45:48 +10:00
|
|
|
/links/(*any)
|
2024-03-12 02:02:21 +11:00
|
|
|
/notifications/(*any)
|
2022-10-26 23:01:02 +11:00
|
|
|
/favourites
|
|
|
|
/bookmarks
|
|
|
|
/pinned
|
2023-11-15 22:13:53 +11:00
|
|
|
/start/(*any)
|
2022-10-26 23:01:02 +11:00
|
|
|
/directory
|
|
|
|
/explore/(*any)
|
|
|
|
/search
|
|
|
|
/publish
|
|
|
|
/follow_requests
|
|
|
|
/blocks
|
|
|
|
/domain_blocks
|
|
|
|
/mutes
|
2023-01-19 02:44:33 +11:00
|
|
|
/followed_tags
|
2022-11-09 03:29:14 +11:00
|
|
|
/statuses/(*any)
|
2023-07-14 01:18:09 +10:00
|
|
|
/deck/(*any)
|
2022-10-26 23:01:02 +11:00
|
|
|
).freeze
|
|
|
|
|
2019-08-30 09:34:33 +10:00
|
|
|
root 'home#index'
|
|
|
|
|
2017-01-22 08:19:13 +11:00
|
|
|
mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
|
2016-08-18 23:49:51 +10:00
|
|
|
|
2021-04-03 11:39:04 +11:00
|
|
|
get 'health', to: 'health#show'
|
2019-09-07 10:47:51 +10:00
|
|
|
|
2023-12-16 01:34:24 +11:00
|
|
|
authenticate :user, ->(user) { user.role&.can?(:view_devops) } do
|
2016-12-13 23:42:10 +11:00
|
|
|
mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
|
|
|
|
mount PgHero::Engine, at: 'pghero', as: :pghero
|
2016-03-25 12:50:48 +11:00
|
|
|
end
|
|
|
|
|
2016-10-23 04:38:47 +11:00
|
|
|
use_doorkeeper do
|
2018-05-20 05:05:08 +10:00
|
|
|
controllers authorizations: 'oauth/authorizations',
|
|
|
|
authorized_applications: 'oauth/authorized_applications',
|
|
|
|
tokens: 'oauth/tokens'
|
2016-10-23 04:38:47 +11:00
|
|
|
end
|
2016-03-07 22:42:33 +11:00
|
|
|
|
2024-07-09 17:34:15 +10:00
|
|
|
scope path: '.well-known' do
|
|
|
|
scope module: :well_known do
|
|
|
|
get 'oauth-authorization-server', to: 'oauth_metadata#show', as: :oauth_metadata, defaults: { format: 'json' }
|
|
|
|
get 'host-meta', to: 'host_meta#show', as: :host_meta, defaults: { format: 'xml' }
|
|
|
|
get 'nodeinfo', to: 'node_info#index', as: :nodeinfo, defaults: { format: 'json' }
|
|
|
|
get 'webfinger', to: 'webfinger#show', as: :webfinger
|
|
|
|
end
|
|
|
|
get 'change-password', to: redirect('/auth/edit'), as: nil
|
|
|
|
get 'proxy', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }, as: nil
|
|
|
|
end
|
2019-03-19 07:00:55 +11:00
|
|
|
|
2023-11-07 03:25:40 +11:00
|
|
|
get '/nodeinfo/2.0', to: 'well_known/node_info#show', as: :nodeinfo_schema
|
2019-09-30 05:31:51 +10:00
|
|
|
|
2017-06-07 03:29:42 +10:00
|
|
|
get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
|
2017-08-14 12:53:31 +10:00
|
|
|
get 'intent', to: 'intents#show'
|
2018-08-24 12:33:27 +10:00
|
|
|
get 'custom.css', to: 'custom_css#show', as: :custom_css
|
2016-02-23 02:00:20 +11:00
|
|
|
|
2023-07-28 00:11:17 +10:00
|
|
|
get 'remote_interaction_helper', to: 'remote_interaction_helper#index'
|
|
|
|
|
2019-07-19 09:44:42 +10:00
|
|
|
resource :instance_actor, path: 'actor', only: [:show] do
|
2024-03-14 20:18:46 +11:00
|
|
|
scope module: :activitypub do
|
|
|
|
resource :inbox, only: [:create]
|
|
|
|
resource :outbox, only: [:show]
|
|
|
|
end
|
2019-07-19 09:44:42 +10:00
|
|
|
end
|
|
|
|
|
2023-11-14 00:27:00 +11:00
|
|
|
get '/invite/:invite_code', constraints: ->(req) { req.format == :json }, to: 'api/v1/invites#show'
|
|
|
|
|
2017-11-28 02:07:59 +11:00
|
|
|
devise_scope :user do
|
|
|
|
get '/invite/:invite_code', to: 'auth/registrations#new', as: :public_invite
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 18:48:50 +10:00
|
|
|
|
2023-06-12 22:22:46 +10:00
|
|
|
resource :unsubscribe, only: [:show, :create], controller: :mail_subscriptions
|
|
|
|
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 18:48:50 +10:00
|
|
|
namespace :auth do
|
|
|
|
resource :setup, only: [:show, :update], controller: :setup
|
2024-07-09 17:34:19 +10:00
|
|
|
resource :challenge, only: [:create]
|
Add WebAuthn as an alternative 2FA method (#14466)
* feat: add possibility of adding WebAuthn security keys to use as 2FA
This adds a basic UI for enabling WebAuthn 2FA. We did a little refactor
to the Settings page for editing the 2FA methods – now it will list the
methods that are available to the user (TOTP and WebAuthn) and from
there they'll be able to add or remove any of them.
Also, it's worth mentioning that for enabling WebAuthn it's required to
have TOTP enabled, so the first time that you go to the 2FA Settings
page, you'll be asked to set it up.
This work was inspired by the one donde by Github in their platform, and
despite it could be approached in different ways, we decided to go with
this one given that we feel that this gives a great UX.
Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com>
* feat: add request for WebAuthn as second factor at login if enabled
This commits adds the feature for using WebAuthn as a second factor for
login when enabled.
If users have WebAuthn enabled, now a page requesting for the use of a
WebAuthn credential for log in will appear, although a link redirecting
to the old page for logging in using a two-factor code will also be
present.
Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com>
* feat: add possibility of deleting WebAuthn Credentials
Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com>
* feat: disable WebAuthn when an Admin disables 2FA for a user
Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com>
* feat: remove ability to disable TOTP leaving only WebAuthn as 2FA
Following examples form other platforms like Github, we decided to make
Webauthn 2FA secondary to 2FA with TOTP, so that we removed the
possibility of removing TOTP authentication only, leaving users with
just WEbAuthn as 2FA. Instead, users will have to click on 'Disable 2FA'
in order to remove second factor auth.
The reason for WebAuthn being secondary to TOPT is that in that way,
users will still be able to log in using their code from their phone's
application if they don't have their security keys with them – or maybe
even lost them.
* We had to change a little the flow for setting up TOTP, given that now
it's possible to setting up again if you already had TOTP, in order to
let users modify their authenticator app – given that now it's not
possible for them to disable TOTP and set it up again with another
authenticator app.
So, basically, now instead of storing the new `otp_secret` in the
user, we store it in the session until the process of set up is
finished.
This was because, as it was before, when users clicked on 'Edit' in
the new two-factor methods lists page, but then went back without
finishing the flow, their `otp_secret` had been changed therefore
invalidating their previous authenticator app, making them unable to
log in again using TOTP.
Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com>
* refactor: fix eslint errors
The PR build was failing given that linting returning some errors.
This commit attempts to fix them.
* refactor: normalize i18n translations
The build was failing given that i18n translations files were not
normalized.
This commits fixes that.
* refactor: avoid having the webauthn gem locked to a specific version
* refactor: use symbols for routes without '/'
* refactor: avoid sending webauthn disabled email when 2FA is disabled
When an admins disable 2FA for users, we were sending two mails
to them, one notifying that 2FA was disabled and the other to notify
that WebAuthn was disabled.
As the second one is redundant since the first email includes it, we can
remove it and send just one email to users.
* refactor: avoid creating new env variable for webauthn_origin config
* refactor: improve flash error messages for webauthn pages
Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com>
2020-08-25 00:46:27 +10:00
|
|
|
get 'sessions/security_key_options', to: 'sessions#webauthn_options'
|
2023-05-17 07:27:35 +10:00
|
|
|
post 'captcha_confirmation', to: 'confirmations#confirm_captcha', as: :captcha_confirmation
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 18:48:50 +10:00
|
|
|
end
|
2017-11-28 02:07:59 +11:00
|
|
|
end
|
|
|
|
|
2024-07-11 21:13:55 +10:00
|
|
|
scope module: :auth do
|
|
|
|
devise_for :users, path: 'auth', format: false
|
|
|
|
end
|
2016-03-05 23:12:24 +11:00
|
|
|
|
2024-01-31 02:39:01 +11:00
|
|
|
with_options constraints: ->(req) { req.format.nil? || req.format.html? } do
|
|
|
|
get '/users/:username', to: redirect_with_vary('/@%{username}')
|
|
|
|
get '/users/:username/following', to: redirect_with_vary('/@%{username}/following')
|
|
|
|
get '/users/:username/followers', to: redirect_with_vary('/@%{username}/followers')
|
|
|
|
get '/users/:username/statuses/:id', to: redirect_with_vary('/@%{username}/%{id}')
|
|
|
|
end
|
2023-11-08 21:31:05 +11:00
|
|
|
|
2018-09-03 08:10:28 +10:00
|
|
|
get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }
|
2017-03-23 05:26:22 +11:00
|
|
|
|
2016-03-01 05:42:08 +11:00
|
|
|
resources :accounts, path: 'users', only: [:show], param: :username do
|
2017-07-15 11:01:39 +10:00
|
|
|
resources :statuses, only: [:show] do
|
|
|
|
member do
|
|
|
|
get :activity
|
2017-08-30 18:23:43 +10:00
|
|
|
get :embed
|
2017-07-15 11:01:39 +10:00
|
|
|
end
|
2019-07-08 20:03:45 +10:00
|
|
|
|
|
|
|
resources :replies, only: [:index], module: :activitypub
|
2017-07-15 11:01:39 +10:00
|
|
|
end
|
|
|
|
|
2017-04-19 21:52:37 +10:00
|
|
|
resources :followers, only: [:index], controller: :follower_accounts
|
|
|
|
resources :following, only: [:index], controller: :following_accounts
|
2018-03-04 19:19:11 +11:00
|
|
|
|
2024-03-14 20:18:41 +11:00
|
|
|
scope module: :activitypub do
|
|
|
|
resource :outbox, only: [:show]
|
|
|
|
resource :inbox, only: [:create]
|
|
|
|
resource :claim, only: [:create]
|
|
|
|
resources :collections, only: [:show]
|
|
|
|
resource :followers_synchronization, only: [:show]
|
|
|
|
end
|
2016-03-01 05:42:08 +11:00
|
|
|
end
|
2016-02-23 02:00:20 +11:00
|
|
|
|
2017-08-31 08:02:59 +10:00
|
|
|
resource :inbox, only: [:create], module: :activitypub
|
|
|
|
|
2024-04-20 06:33:00 +10:00
|
|
|
get '/:encoded_at(*path)', to: redirect('/@%{path}'), constraints: { encoded_at: /%40/ }
|
2023-02-15 05:05:57 +11:00
|
|
|
|
2023-06-06 22:50:51 +10:00
|
|
|
constraints(username: %r{[^@/.]+}) do
|
2024-03-14 21:03:38 +11:00
|
|
|
with_options to: 'accounts#show' do
|
|
|
|
get '/@:username', as: :short_account
|
|
|
|
get '/@:username/with_replies', as: :short_account_with_replies
|
|
|
|
get '/@:username/media', as: :short_account_media
|
|
|
|
get '/@:username/tagged/:tag', as: :short_account_tag
|
|
|
|
end
|
2022-10-20 23:35:29 +11:00
|
|
|
end
|
2017-03-23 05:26:22 +11:00
|
|
|
|
2023-06-06 22:50:51 +10:00
|
|
|
constraints(account_username: %r{[^@/.]+}) do
|
2022-10-20 23:35:29 +11:00
|
|
|
get '/@:account_username/following', to: 'following_accounts#index'
|
|
|
|
get '/@:account_username/followers', to: 'follower_accounts#index'
|
|
|
|
get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
|
|
|
|
get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
|
|
|
|
end
|
2018-08-18 11:03:12 +10:00
|
|
|
|
2023-10-27 19:35:21 +11:00
|
|
|
get '/@:username_with_domain/(*any)', to: 'home#index', constraints: { username_with_domain: %r{([^/])+?} }, as: :account_with_domain, format: false
|
2019-06-08 00:51:08 +10:00
|
|
|
get '/settings', to: redirect('/settings/profile')
|
2019-06-07 11:39:24 +10:00
|
|
|
|
2023-05-02 23:41:20 +10:00
|
|
|
draw(:settings)
|
2016-10-14 11:28:49 +11:00
|
|
|
|
2022-02-15 07:27:53 +11:00
|
|
|
namespace :disputes do
|
2022-03-02 05:37:47 +11:00
|
|
|
resources :strikes, only: [:show, :index] do
|
2022-02-15 07:27:53 +11:00
|
|
|
resource :appeal, only: [:create]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-01-24 21:49:19 +11:00
|
|
|
namespace :redirect do
|
|
|
|
resources :accounts, only: :show
|
|
|
|
resources :statuses, only: :show
|
|
|
|
end
|
|
|
|
|
2018-02-16 17:22:20 +11:00
|
|
|
resources :media, only: [:show] do
|
|
|
|
get :player
|
|
|
|
end
|
|
|
|
|
2017-10-08 02:43:42 +11:00
|
|
|
resources :tags, only: [:show]
|
|
|
|
resources :emojis, only: [:show]
|
2017-11-28 02:07:59 +11:00
|
|
|
resources :invites, only: [:index, :create, :destroy]
|
2022-08-25 12:27:47 +10:00
|
|
|
resources :filters, except: [:show] do
|
|
|
|
resources :statuses, only: [:index], controller: 'filters/statuses' do
|
|
|
|
collection do
|
|
|
|
post :batch
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-16 21:23:22 +11:00
|
|
|
resource :relationships, only: [:show, :update]
|
2024-03-21 02:37:21 +11:00
|
|
|
resources :severed_relationships, only: [:index] do
|
|
|
|
member do
|
|
|
|
constraints(format: :csv) do
|
|
|
|
get :followers
|
|
|
|
get :following
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-08-10 07:11:50 +10:00
|
|
|
resource :statuses_cleanup, controller: :statuses_cleanup, only: [:show, :update]
|
2016-10-03 01:14:21 +11:00
|
|
|
|
2022-11-15 06:26:31 +11:00
|
|
|
get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy, format: false
|
2023-03-17 08:46:52 +11:00
|
|
|
get '/backups/:id/download', to: 'backups#download', as: :download_backup, format: false
|
2017-09-16 11:01:45 +10:00
|
|
|
|
2023-07-28 00:11:17 +10:00
|
|
|
resource :authorize_interaction, only: [:show]
|
2023-07-02 05:48:53 +10:00
|
|
|
resource :share, only: [:show]
|
2016-12-30 02:54:54 +11:00
|
|
|
|
2023-05-02 23:41:20 +10:00
|
|
|
draw(:admin)
|
2016-11-29 04:45:13 +11:00
|
|
|
|
2018-07-16 09:11:53 +10:00
|
|
|
get '/admin', to: redirect('/admin/dashboard', status: 302)
|
2017-01-26 18:59:35 +11:00
|
|
|
|
2023-05-02 23:41:20 +10:00
|
|
|
draw(:api)
|
2016-02-23 02:00:20 +11:00
|
|
|
|
2022-10-26 23:01:02 +11:00
|
|
|
web_app_paths.each do |path|
|
2022-10-20 23:35:29 +11:00
|
|
|
get path, to: 'home#index'
|
|
|
|
end
|
2016-11-14 00:01:21 +11:00
|
|
|
|
2022-11-09 11:30:33 +11:00
|
|
|
get '/web/(*any)', to: redirect('/%{any}', status: 302), as: :web, defaults: { any: '' }, format: false
|
2022-10-27 01:56:37 +11:00
|
|
|
get '/about', to: 'about#show'
|
|
|
|
get '/about/more', to: redirect('/about')
|
2022-09-29 14:22:12 +10:00
|
|
|
|
|
|
|
get '/privacy-policy', to: 'privacy#show', as: :privacy_policy
|
|
|
|
get '/terms', to: redirect('/privacy-policy')
|
2017-01-20 11:00:14 +11:00
|
|
|
|
2019-08-30 09:34:33 +10:00
|
|
|
match '/', via: [:post, :put, :patch, :delete], to: 'application#raise_not_found', format: false
|
|
|
|
match '*unmatched_route', via: :all, to: 'application#raise_not_found', format: false
|
2016-02-21 08:53:20 +11:00
|
|
|
end
|