2021-03-11 19:13:27 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
require 'sidekiq/web'
|
2015-12-23 02:04:40 +05:30
|
|
|
require 'sidekiq/cron/web'
|
2020-07-28 23:09:34 +05:30
|
|
|
require 'product_analytics/collector_app'
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
Rails.application.routes.draw do
|
2016-06-16 23:09:34 +05:30
|
|
|
concern :access_requestable do
|
|
|
|
post :request_access, on: :collection
|
|
|
|
post :approve_access_request, on: :member
|
|
|
|
end
|
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
concern :awardable do
|
|
|
|
post :toggle_award_emoji, on: :member
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
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-11-03 12:29:30 +05:30
|
|
|
draw :sherlock
|
|
|
|
draw :development
|
2015-09-25 12:07:36 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
use_doorkeeper do
|
|
|
|
controllers applications: 'oauth/applications',
|
|
|
|
authorized_applications: 'oauth/authorized_applications',
|
2020-03-13 15:44:24 +05:30
|
|
|
authorizations: 'oauth/authorizations',
|
2020-08-18 19:51:02 +05:30
|
|
|
token_info: 'oauth/token_info',
|
|
|
|
tokens: 'oauth/tokens'
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
# This prefixless path is required because Jira gets confused if we set it up with a path
|
2019-12-04 20:38:33 +05:30
|
|
|
# More information: https://gitlab.com/gitlab-org/gitlab/issues/6752
|
2018-11-20 20:47:30 +05:30
|
|
|
scope path: '/login/oauth', controller: 'oauth/jira/authorizations', as: :oauth_jira do
|
2020-11-24 15:15:51 +05:30
|
|
|
get :authorize, action: :new
|
|
|
|
get :callback
|
|
|
|
post :access_token
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
match '*all', via: [:get, :post], to: proc { [404, {}, ['']] }
|
2018-11-20 20:47:30 +05:30
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
draw :oauth
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
use_doorkeeper_openid_connect
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
# Sign up
|
2020-06-23 00:09:42 +05:30
|
|
|
scope path: '/users/sign_up', module: :registrations, as: :users_sign_up do
|
2021-03-08 18:12:59 +05:30
|
|
|
resource :welcome, only: [:show, :update], controller: 'welcome' do
|
|
|
|
Gitlab.ee do
|
|
|
|
get :trial_getting_started, on: :collection
|
2021-04-17 20:07:23 +05:30
|
|
|
get :trial_onboarding_board, on: :collection
|
2021-03-08 18:12:59 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
resource :experience_level, only: [:show, :update]
|
|
|
|
|
|
|
|
Gitlab.ee do
|
|
|
|
resources :groups, only: [:new, :create]
|
2021-04-17 20:07:23 +05:30
|
|
|
resources :group_invites, only: [:new, :create]
|
2020-06-23 00:09:42 +05:30
|
|
|
resources :projects, only: [:new, :create]
|
|
|
|
end
|
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
# Search
|
2021-03-11 19:13:27 +05:30
|
|
|
get 'search' => 'search#show', as: :search
|
2020-07-28 23:09:34 +05:30
|
|
|
get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
|
2019-10-12 21:52:04 +05:30
|
|
|
get 'search/count' => 'search#count', as: :search_count
|
2021-03-11 19:13:27 +05:30
|
|
|
get 'search/opensearch' => 'search#opensearch', as: :search_opensearch
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
# JSON Web Token
|
|
|
|
get 'jwt/auth' => 'jwt#auth'
|
|
|
|
|
|
|
|
# Health check
|
|
|
|
get 'health_check(/:checks)' => 'health_check#index', as: :health_check
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
# Begin of the /-/ scope.
|
|
|
|
# Use this scope for all new global routes.
|
2017-09-10 17:25:29 +05:30
|
|
|
scope path: '-' do
|
2020-05-24 23:13:21 +05:30
|
|
|
# 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-28 23:09:34 +05:30
|
|
|
get '/autocomplete/deploy_keys_with_owners' => 'autocomplete#deploy_keys_with_owners'
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
get '/whats_new' => 'whats_new#index'
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
# '/-/health' implemented by BasicHealthCheck middleware
|
2017-09-10 17:25:29 +05:30
|
|
|
get 'liveness' => 'health#liveness'
|
|
|
|
get 'readiness' => 'health#readiness'
|
2021-03-08 18:12:59 +05:30
|
|
|
controller :metrics do
|
|
|
|
get 'metrics', action: :index
|
|
|
|
get 'metrics/system', action: :system
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
mount Peek::Railtie => '/peek', as: 'peek_routes'
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
get 'runner_setup/platforms' => 'runner_setup#platforms'
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
# 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-09-30 21:07:59 +05:30
|
|
|
resources :issues, module: :boards, only: [:index, :update] do
|
|
|
|
collection do
|
|
|
|
put :bulk_move, format: :json
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Gitlab.ee do
|
|
|
|
resources :users, module: :boards, only: [:index]
|
|
|
|
resources :milestones, module: :boards, only: [:index]
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
get 'acme-challenge/' => 'acme_challenges#show'
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
# UserCallouts
|
|
|
|
resources :user_callouts, only: [:create]
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
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-11-18 11:00:15 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
draw :operations
|
2020-11-24 15:15:51 +05:30
|
|
|
draw :jira_connect
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
Gitlab.ee do
|
2019-12-04 20:38:33 +05:30
|
|
|
draw :security
|
2019-09-30 21:07:59 +05:30
|
|
|
draw :smartcard
|
2019-12-04 20:38:33 +05:30
|
|
|
draw :username
|
|
|
|
draw :trial
|
|
|
|
draw :trial_registration
|
|
|
|
draw :country
|
2020-01-01 13:55:28 +05:30
|
|
|
draw :country_state
|
|
|
|
draw :subscription
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
scope '/push_from_secondary/:geo_node_id' do
|
|
|
|
draw :git_http
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
# Used for survey responses
|
|
|
|
resources :survey_responses, only: :index
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
if ENV['GITLAB_CHAOS_SECRET'] || Rails.env.development? || Rails.env.test?
|
2019-09-30 21:07:59 +05:30
|
|
|
resource :chaos, only: [] do
|
|
|
|
get :leakmem
|
|
|
|
get :cpu_spin
|
|
|
|
get :db_spin
|
|
|
|
get :sleep
|
|
|
|
get :kill
|
2021-03-11 19:13:27 +05:30
|
|
|
post :gc
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
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]
|
|
|
|
|
|
|
|
# JWKS (JSON Web Key Set) endpoint
|
2021-01-29 00:20:46 +05:30
|
|
|
# Used by third parties to verify CI_JOB_JWT
|
|
|
|
get 'jwks' => 'jwks#index'
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
draw :snippets
|
2021-01-29 00:20:46 +05:30
|
|
|
draw :profile
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
# Product analytics collector
|
|
|
|
match '/collector/i', to: ProductAnalytics::CollectorApp.new, via: :all
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
# End of the /-/ scope.
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
concern :clusterable do
|
|
|
|
resources :clusters, only: [:index, :new, :show, :update, :destroy] do
|
|
|
|
collection do
|
|
|
|
post :create_user
|
|
|
|
post :create_gcp
|
2019-12-26 22:10:19 +05:30
|
|
|
post :create_aws
|
|
|
|
post :authorize_aws_role
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
member do
|
2019-09-30 21:07:59 +05:30
|
|
|
Gitlab.ee do
|
|
|
|
get :metrics, format: :json
|
2019-12-21 20:55:43 +05:30
|
|
|
get :environments, format: :json
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
scope :applications do
|
|
|
|
post '/:application', to: 'clusters/applications#create', as: :install_applications
|
2019-07-07 11:18:12 +05:30
|
|
|
patch '/:application', to: 'clusters/applications#update', as: :update_applications
|
2019-07-31 22:56:46 +05:30
|
|
|
delete '/:application', to: 'clusters/applications#destroy', as: :uninstall_applications
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
get :metrics_dashboard
|
|
|
|
get :'/prometheus/api/v1/*proxy_path', to: 'clusters#prometheus_proxy', as: :prometheus_api
|
2018-12-13 13:39:08 +05:30
|
|
|
get :cluster_status, format: :json
|
2020-01-01 13:55:28 +05:30
|
|
|
delete :clear_cache
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
# Deprecated routes.
|
|
|
|
# Will be removed as part of https://gitlab.com/gitlab-org/gitlab/-/issues/210024
|
|
|
|
scope as: :deprecated do
|
2020-05-24 23:13:21 +05:30
|
|
|
# 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'
|
|
|
|
|
|
|
|
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-04-22 19:07:51 +05:30
|
|
|
resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do
|
|
|
|
member do
|
|
|
|
post :accept
|
|
|
|
match :decline, via: [:get, :post]
|
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do
|
|
|
|
member do
|
|
|
|
get :unsubscribe
|
|
|
|
end
|
2016-01-19 16:12:03 +05:30
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
resources :abuse_reports, only: [:new, :create]
|
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
resources :groups, only: [:index, :new, :create] do
|
|
|
|
post :preview_markdown
|
|
|
|
end
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
draw :group
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
resources :projects, only: [:index, :new, :create]
|
|
|
|
|
|
|
|
get '/projects/:id' => 'projects#resolve'
|
|
|
|
|
|
|
|
draw :git_http
|
|
|
|
draw :api
|
|
|
|
draw :sidekiq
|
|
|
|
draw :help
|
2018-03-17 18:26:18 +05:30
|
|
|
draw :google_api
|
2016-11-03 12:29:30 +05:30
|
|
|
draw :import
|
|
|
|
draw :uploads
|
|
|
|
draw :explore
|
|
|
|
draw :admin
|
|
|
|
draw :dashboard
|
|
|
|
draw :user
|
|
|
|
draw :project
|
2021-02-04 15:43:07 +05:30
|
|
|
draw :unmatched_project
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
# Issue https://gitlab.com/gitlab-org/gitlab/-/issues/210024
|
2020-10-24 23:57:45 +05:30
|
|
|
scope as: 'deprecated' do
|
2020-07-28 23:09:34 +05:30
|
|
|
draw :snippets
|
2021-03-08 18:12:59 +05:30
|
|
|
|
|
|
|
Gitlab::Routing.redirect_legacy_paths(self, :profile)
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
Gitlab.ee do
|
|
|
|
get '/sitemap' => 'sitemap#show', format: :xml
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
# 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
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
root to: "root#index"
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
get '*unmatched_route', to: 'application#route_not_found'
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
Gitlab::Routing.add_helpers(TimeboxesRoutingHelper)
|