2021-02-03 16:09:17 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-01-09 00:14:05 -05:00
|
|
|
require 'sidekiq/web'
|
2015-12-03 18:24:39 -05:00
|
|
|
require 'sidekiq/cron/web'
|
2020-07-16 20:09:37 -04:00
|
|
|
require 'product_analytics/collector_app'
|
2013-01-09 00:14:05 -05:00
|
|
|
|
2015-11-25 11:18:44 -05:00
|
|
|
Rails.application.routes.draw do
|
2016-06-01 12:07:23 -04:00
|
|
|
concern :access_requestable do
|
|
|
|
post :request_access, on: :collection
|
2016-06-01 12:17:03 -04:00
|
|
|
post :approve_access_request, on: :member
|
2016-06-01 12:07:23 -04:00
|
|
|
end
|
|
|
|
|
2016-09-19 03:26:37 -04:00
|
|
|
concern :awardable do
|
|
|
|
post :toggle_award_emoji, on: :member
|
|
|
|
end
|
|
|
|
|
2018-06-18 05:31:37 -04:00
|
|
|
favicon_redirect = redirect do |_params, _request|
|
|
|
|
ActionController::Base.helpers.asset_url(Gitlab::Favicon.main)
|
|
|
|
end
|
|
|
|
get 'favicon.png', to: favicon_redirect
|
|
|
|
get 'favicon.ico', to: favicon_redirect
|
|
|
|
|
2016-10-05 11:43:47 -04:00
|
|
|
draw :sherlock
|
|
|
|
draw :development
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2014-12-19 09:15:29 -05:00
|
|
|
use_doorkeeper do
|
2015-02-02 22:30:09 -05:00
|
|
|
controllers applications: 'oauth/applications',
|
|
|
|
authorized_applications: 'oauth/authorized_applications',
|
2020-02-17 22:08:54 -05:00
|
|
|
authorizations: 'oauth/authorizations',
|
2020-08-05 17:09:40 -04:00
|
|
|
token_info: 'oauth/token_info',
|
|
|
|
tokens: 'oauth/tokens'
|
2014-12-19 09:15:29 -05:00
|
|
|
end
|
2015-03-08 17:46:22 -04:00
|
|
|
|
2019-06-24 12:53:17 -04:00
|
|
|
# This prefixless path is required because Jira gets confused if we set it up with a path
|
2019-09-18 10:02:45 -04:00
|
|
|
# More information: https://gitlab.com/gitlab-org/gitlab/issues/6752
|
2018-08-16 21:05:07 -04:00
|
|
|
scope path: '/login/oauth', controller: 'oauth/jira/authorizations', as: :oauth_jira do
|
2020-09-01 08:11:01 -04:00
|
|
|
get :authorize, action: :new
|
|
|
|
get :callback
|
|
|
|
post :access_token
|
2019-06-25 14:53:57 -04:00
|
|
|
|
2018-09-11 16:46:02 -04:00
|
|
|
match '*all', via: [:get, :post], to: proc { [404, {}, ['']] }
|
2018-08-16 21:05:07 -04:00
|
|
|
end
|
|
|
|
|
2018-10-17 12:55:42 -04:00
|
|
|
draw :oauth
|
|
|
|
|
2016-12-09 12:36:50 -05:00
|
|
|
use_doorkeeper_openid_connect
|
2021-06-09 11:10:05 -04:00
|
|
|
# Add OPTIONS method for CORS preflight requests
|
|
|
|
match '/oauth/userinfo' => 'doorkeeper/openid_connect/userinfo#show', via: :options
|
|
|
|
match '/oauth/discovery/keys' => 'doorkeeper/openid_connect/discovery#keys', via: :options
|
|
|
|
match '/.well-known/openid-configuration' => 'doorkeeper/openid_connect/discovery#provider', via: :options
|
|
|
|
match '/.well-known/webfinger' => 'doorkeeper/openid_connect/discovery#webfinger', via: :options
|
|
|
|
|
|
|
|
match '/oauth/token' => 'oauth/tokens#create', via: :options
|
|
|
|
match '/oauth/revoke' => 'oauth/tokens#revoke', via: :options
|
2016-12-09 12:36:50 -05:00
|
|
|
|
2019-10-18 17:06:37 -04:00
|
|
|
# Sign up
|
2020-05-29 02:08:16 -04:00
|
|
|
scope path: '/users/sign_up', module: :registrations, as: :users_sign_up do
|
2020-12-28 04:10:18 -05:00
|
|
|
resource :welcome, only: [:show, :update], controller: 'welcome' do
|
|
|
|
Gitlab.ee do
|
|
|
|
get :trial_getting_started, on: :collection
|
2021-02-23 07:10:56 -05:00
|
|
|
get :trial_onboarding_board, on: :collection
|
2021-04-20 11:09:24 -04:00
|
|
|
get :continuous_onboarding_getting_started, on: :collection
|
2020-12-28 04:10:18 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-10 20:08:35 -04:00
|
|
|
resource :experience_level, only: [:show, :update]
|
2020-05-29 02:08:16 -04:00
|
|
|
|
|
|
|
Gitlab.ee do
|
|
|
|
resources :groups, only: [:new, :create]
|
2021-03-02 13:11:20 -05:00
|
|
|
resources :group_invites, only: [:new, :create]
|
2020-05-29 08:08:19 -04:00
|
|
|
resources :projects, only: [:new, :create]
|
2020-05-29 02:08:16 -04:00
|
|
|
end
|
|
|
|
end
|
2019-10-18 17:06:37 -04:00
|
|
|
|
2012-06-13 02:03:53 -04:00
|
|
|
# Search
|
2021-02-01 07:09:03 -05:00
|
|
|
get 'search' => 'search#show', as: :search
|
2020-07-10 05:09:01 -04:00
|
|
|
get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
|
2019-07-15 13:59:57 -04:00
|
|
|
get 'search/count' => 'search#count', as: :search_count
|
2021-02-01 07:09:03 -05:00
|
|
|
get 'search/opensearch' => 'search#opensearch', as: :search_opensearch
|
2012-02-19 09:35:31 -05:00
|
|
|
|
2016-05-02 07:29:17 -04:00
|
|
|
# JSON Web Token
|
|
|
|
get 'jwt/auth' => 'jwt#auth'
|
|
|
|
|
2016-04-22 12:50:08 -04:00
|
|
|
# Health check
|
2016-05-13 03:51:13 -04:00
|
|
|
get 'health_check(/:checks)' => 'health_check#index', as: :health_check
|
2016-04-22 12:50:08 -04:00
|
|
|
|
2021-05-13 20:11:05 -04:00
|
|
|
# Terraform service discovery
|
|
|
|
get '.well-known/terraform.json' => 'terraform/services#index', as: :terraform_services
|
|
|
|
|
2020-03-30 11:07:51 -04:00
|
|
|
# Begin of the /-/ scope.
|
|
|
|
# Use this scope for all new global routes.
|
2017-05-19 12:27:36 -04:00
|
|
|
scope path: '-' do
|
2020-04-24 11:09:37 -04:00
|
|
|
# Autocomplete
|
|
|
|
get '/autocomplete/users' => 'autocomplete#users'
|
|
|
|
get '/autocomplete/users/:id' => 'autocomplete#user'
|
|
|
|
get '/autocomplete/projects' => 'autocomplete#projects'
|
|
|
|
get '/autocomplete/award_emojis' => 'autocomplete#award_emojis'
|
|
|
|
get '/autocomplete/merge_request_target_branches' => 'autocomplete#merge_request_target_branches'
|
2020-07-15 08:09:26 -04:00
|
|
|
get '/autocomplete/deploy_keys_with_owners' => 'autocomplete#deploy_keys_with_owners'
|
2020-04-24 11:09:37 -04:00
|
|
|
|
|
|
|
Gitlab.ee do
|
|
|
|
get '/autocomplete/project_groups' => 'autocomplete#project_groups'
|
|
|
|
get '/autocomplete/project_routes' => 'autocomplete#project_routes'
|
|
|
|
get '/autocomplete/namespace_routes' => 'autocomplete#namespace_routes'
|
|
|
|
end
|
|
|
|
|
2020-10-14 14:08:47 -04:00
|
|
|
get '/whats_new' => 'whats_new#index'
|
|
|
|
|
2019-09-03 12:15:47 -04:00
|
|
|
# '/-/health' implemented by BasicHealthCheck middleware
|
2017-05-19 12:27:36 -04:00
|
|
|
get 'liveness' => 'health#liveness'
|
|
|
|
get 'readiness' => 'health#readiness'
|
2021-01-13 07:10:27 -05:00
|
|
|
controller :metrics do
|
|
|
|
get 'metrics', action: :index
|
|
|
|
get 'metrics/system', action: :system
|
|
|
|
end
|
2018-03-19 15:06:09 -04:00
|
|
|
mount Peek::Railtie => '/peek', as: 'peek_routes'
|
2017-10-13 04:28:25 -04:00
|
|
|
|
2020-09-30 17:10:09 -04:00
|
|
|
get 'runner_setup/platforms' => 'runner_setup#platforms'
|
|
|
|
|
2017-10-13 04:28:25 -04:00
|
|
|
# Boards resources shared between group and projects
|
|
|
|
resources :boards, only: [] do
|
|
|
|
resources :lists, module: :boards, only: [:index, :create, :update, :destroy] do
|
|
|
|
collection do
|
|
|
|
post :generate
|
|
|
|
end
|
|
|
|
|
|
|
|
resources :issues, only: [:index, :create, :update]
|
|
|
|
end
|
|
|
|
|
2019-07-11 09:29:16 -04:00
|
|
|
resources :issues, module: :boards, only: [:index, :update] do
|
|
|
|
collection do
|
|
|
|
put :bulk_move, format: :json
|
|
|
|
end
|
|
|
|
end
|
2019-06-24 12:53:17 -04:00
|
|
|
|
2019-06-25 14:53:57 -04:00
|
|
|
Gitlab.ee do
|
|
|
|
resources :users, module: :boards, only: [:index]
|
|
|
|
resources :milestones, module: :boards, only: [:index]
|
|
|
|
end
|
2017-10-13 04:28:25 -04:00
|
|
|
end
|
2018-01-27 12:44:14 -05:00
|
|
|
|
2019-06-06 14:55:31 -04:00
|
|
|
get 'acme-challenge/' => 'acme_challenges#show'
|
|
|
|
|
2018-10-31 20:39:01 -04:00
|
|
|
# UserCallouts
|
|
|
|
resources :user_callouts, only: [:create]
|
|
|
|
|
2021-03-05 10:09:12 -05:00
|
|
|
scope :ide, as: :ide, format: false do
|
|
|
|
get '/', to: 'ide#index'
|
|
|
|
get '/project', to: 'ide#index'
|
|
|
|
|
|
|
|
scope path: 'project/:project_id', as: :project, constraints: { project_id: Gitlab::PathRegex.full_namespace_route_regex } do
|
|
|
|
%w[edit tree blob].each do |action|
|
|
|
|
get "/#{action}", to: 'ide#index'
|
|
|
|
get "/#{action}/*branch/-/*path", to: 'ide#index'
|
|
|
|
get "/#{action}/*branch/-", to: 'ide#index'
|
|
|
|
get "/#{action}/*branch", to: 'ide#index'
|
|
|
|
end
|
|
|
|
|
|
|
|
get '/merge_requests/:merge_request_id', to: 'ide#index', constraints: { merge_request_id: /\d+/ }
|
|
|
|
get '/', to: 'ide#index'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
resource :projects
|
2018-10-31 20:39:01 -04:00
|
|
|
|
|
|
|
draw :operations
|
2020-09-01 08:11:01 -04:00
|
|
|
draw :jira_connect
|
2019-06-25 14:53:57 -04:00
|
|
|
|
|
|
|
Gitlab.ee do
|
2019-09-05 15:07:04 -04:00
|
|
|
draw :security
|
2019-06-25 14:53:57 -04:00
|
|
|
draw :smartcard
|
2019-08-19 21:18:00 -04:00
|
|
|
draw :username
|
2019-09-13 09:26:31 -04:00
|
|
|
draw :trial
|
2019-08-26 18:16:03 -04:00
|
|
|
draw :trial_registration
|
2019-09-11 12:02:11 -04:00
|
|
|
draw :country
|
2019-12-10 19:08:25 -05:00
|
|
|
draw :country_state
|
2019-12-12 07:07:33 -05:00
|
|
|
draw :subscription
|
2020-03-30 11:07:51 -04:00
|
|
|
|
|
|
|
scope '/push_from_secondary/:geo_node_id' do
|
|
|
|
draw :git_http
|
|
|
|
end
|
2020-05-11 08:10:28 -04:00
|
|
|
|
|
|
|
# Used for survey responses
|
|
|
|
resources :survey_responses, only: :index
|
2019-07-10 16:26:34 -04:00
|
|
|
end
|
|
|
|
|
2019-07-16 16:10:44 -04:00
|
|
|
if ENV['GITLAB_CHAOS_SECRET'] || Rails.env.development? || Rails.env.test?
|
2019-07-10 05:43:51 -04:00
|
|
|
resource :chaos, only: [] do
|
|
|
|
get :leakmem
|
|
|
|
get :cpu_spin
|
|
|
|
get :db_spin
|
|
|
|
get :sleep
|
|
|
|
get :kill
|
2021-04-09 02:09:30 -04:00
|
|
|
get :quit
|
2021-01-21 10:08:36 -05:00
|
|
|
post :gc
|
2019-07-10 05:43:51 -04:00
|
|
|
end
|
2018-11-01 13:20:34 -04:00
|
|
|
end
|
2020-03-12 20:09:34 -04:00
|
|
|
|
2020-03-30 11:07:51 -04:00
|
|
|
resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do
|
|
|
|
member do
|
|
|
|
post :accept
|
|
|
|
match :decline, via: [:get, :post]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do
|
|
|
|
member do
|
|
|
|
get :unsubscribe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Spam reports
|
|
|
|
resources :abuse_reports, only: [:new, :create]
|
2020-04-21 11:21:10 -04:00
|
|
|
|
|
|
|
# JWKS (JSON Web Key Set) endpoint
|
2020-10-22 08:08:41 -04:00
|
|
|
# Used by third parties to verify CI_JOB_JWT
|
|
|
|
get 'jwks' => 'jwks#index'
|
2020-07-16 20:09:37 -04:00
|
|
|
|
2020-07-23 11:09:28 -04:00
|
|
|
draw :snippets
|
2020-10-20 08:08:54 -04:00
|
|
|
draw :profile
|
2020-07-23 11:09:28 -04:00
|
|
|
|
2020-07-16 20:09:37 -04:00
|
|
|
# Product analytics collector
|
|
|
|
match '/collector/i', to: ProductAnalytics::CollectorApp.new, via: :all
|
2018-10-31 20:39:01 -04:00
|
|
|
end
|
2020-03-30 11:07:51 -04:00
|
|
|
# End of the /-/ scope.
|
2018-10-31 20:39:01 -04:00
|
|
|
|
|
|
|
concern :clusterable do
|
|
|
|
resources :clusters, only: [:index, :new, :show, :update, :destroy] do
|
2018-10-18 21:42:30 -04:00
|
|
|
collection do
|
|
|
|
post :create_user
|
|
|
|
post :create_gcp
|
2019-11-13 01:06:38 -05:00
|
|
|
post :create_aws
|
2019-11-08 01:06:24 -05:00
|
|
|
post :authorize_aws_role
|
2018-10-18 21:42:30 -04:00
|
|
|
end
|
|
|
|
|
2021-04-06 20:09:26 -04:00
|
|
|
resource :integration, controller: 'clusters/integrations', only: [] do
|
|
|
|
collection do
|
|
|
|
post :create_or_update
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-18 21:42:30 -04:00
|
|
|
member do
|
2019-06-24 12:53:17 -04:00
|
|
|
Gitlab.ee do
|
|
|
|
get :metrics, format: :json
|
2019-10-15 02:07:25 -04:00
|
|
|
get :environments, format: :json
|
2019-06-24 12:53:17 -04:00
|
|
|
end
|
|
|
|
|
2018-10-18 21:42:30 -04:00
|
|
|
scope :applications do
|
|
|
|
post '/:application', to: 'clusters/applications#create', as: :install_applications
|
2019-02-18 12:06:51 -05:00
|
|
|
patch '/:application', to: 'clusters/applications#update', as: :update_applications
|
2019-04-12 08:19:28 -04:00
|
|
|
delete '/:application', to: 'clusters/applications#destroy', as: :uninstall_applications
|
2018-10-18 21:42:30 -04:00
|
|
|
end
|
|
|
|
|
2020-07-13 11:09:08 -04:00
|
|
|
get :metrics_dashboard
|
2020-07-07 02:09:06 -04:00
|
|
|
get :'/prometheus/api/v1/*proxy_path', to: 'clusters#prometheus_proxy', as: :prometheus_api
|
2018-10-31 20:39:01 -04:00
|
|
|
get :cluster_status, format: :json
|
2019-11-26 04:08:36 -05:00
|
|
|
delete :clear_cache
|
2018-10-18 21:42:30 -04:00
|
|
|
end
|
|
|
|
end
|
2018-10-14 23:37:51 -04:00
|
|
|
end
|
|
|
|
|
2020-01-28 13:08:35 -05:00
|
|
|
resources :groups, only: [:index, :new, :create] do
|
|
|
|
post :preview_markdown
|
|
|
|
end
|
|
|
|
|
2020-07-08 08:09:33 -04:00
|
|
|
draw :group
|
|
|
|
|
2020-01-28 13:08:35 -05:00
|
|
|
resources :projects, only: [:index, :new, :create]
|
|
|
|
|
|
|
|
get '/projects/:id' => 'projects#resolve'
|
|
|
|
|
|
|
|
draw :git_http
|
|
|
|
draw :api
|
2021-03-26 14:09:16 -04:00
|
|
|
draw :customers_dot
|
2020-01-28 13:08:35 -05:00
|
|
|
draw :sidekiq
|
|
|
|
draw :help
|
2017-09-25 03:10:25 -04:00
|
|
|
draw :google_api
|
2016-10-05 08:21:27 -04:00
|
|
|
draw :import
|
|
|
|
draw :uploads
|
|
|
|
draw :explore
|
|
|
|
draw :admin
|
|
|
|
draw :dashboard
|
|
|
|
draw :user
|
|
|
|
draw :project
|
2021-02-01 19:09:14 -05:00
|
|
|
draw :unmatched_project
|
2011-10-08 17:36:38 -04:00
|
|
|
|
2020-06-22 14:08:47 -04:00
|
|
|
# Issue https://gitlab.com/gitlab-org/gitlab/-/issues/210024
|
2020-07-23 11:09:28 -04:00
|
|
|
scope as: 'deprecated' do
|
2021-06-01 11:09:52 -04:00
|
|
|
# Issue https://gitlab.com/gitlab-org/gitlab/-/issues/223719
|
|
|
|
get '/snippets/:id/raw',
|
|
|
|
to: 'snippets#raw',
|
|
|
|
format: false,
|
|
|
|
constraints: { id: /\d+/ }
|
2021-01-18 10:10:42 -05:00
|
|
|
|
2021-06-09 14:11:25 -04:00
|
|
|
Gitlab::Routing.redirect_legacy_paths(self, :snippets)
|
2020-10-14 14:08:47 -04:00
|
|
|
end
|
|
|
|
|
2020-11-05 07:09:05 -05:00
|
|
|
Gitlab.ee do
|
|
|
|
get '/sitemap' => 'sitemap#show', format: :xml
|
|
|
|
end
|
|
|
|
|
2021-01-25 04:09:10 -05:00
|
|
|
# Creates shorthand helper methods for project resources.
|
|
|
|
# For example; for the `namespace_project_path` this also creates `project_path`.
|
|
|
|
#
|
|
|
|
# TODO: We don't need the `Gitlab::Routing` module at all as we can use
|
|
|
|
# the `direct` DSL method of Rails to define url helpers. Move all the
|
|
|
|
# custom url helpers to use the `direct` DSL method and remove the `Gitlab::Routing`.
|
|
|
|
# For more information: https://gitlab.com/gitlab-org/gitlab/-/issues/299583
|
|
|
|
Gitlab::Application.routes.set.filter_map { |route| route.name if route.name&.include?('namespace_project') }.each do |name|
|
|
|
|
new_name = name.sub('namespace_project', 'project')
|
|
|
|
|
|
|
|
direct(new_name) do |project, *args|
|
|
|
|
# This is due to a bug I've found in Rails.
|
|
|
|
# For more information: https://gitlab.com/gitlab-org/gitlab/-/issues/299591
|
|
|
|
args.pop if args.last == {}
|
|
|
|
|
|
|
|
send("#{name}_url", project&.namespace, project, *args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-08 09:49:20 -04:00
|
|
|
root to: "root#index"
|
2016-10-14 17:11:19 -04:00
|
|
|
|
2016-11-14 09:55:31 -05:00
|
|
|
get '*unmatched_route', to: 'application#route_not_found'
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
2021-01-25 04:09:10 -05:00
|
|
|
|
|
|
|
Gitlab::Routing.add_helpers(TimeboxesRoutingHelper)
|