-
-
Notifications
You must be signed in to change notification settings - Fork 929
/
routes.rb
319 lines (271 loc) · 10.8 KB
/
routes.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
Rails.application.routes.draw do
################################################################################
# Root
root to: 'home#index'
################################################################################
# API
namespace :api do
namespace :v2 do
resources :rubygems, param: :name, only: [], constraints: { name: Patterns::ROUTE_PATTERN } do
resources :versions, param: :number, only: :show, constraints: {
number: /#{Gem::Version::VERSION_PATTERN}(?=\.(json|yaml|sha256)\z)|#{Gem::Version::VERSION_PATTERN}/o
} do
resources :contents, only: :index, constraints: {
version_number: /#{Gem::Version::VERSION_PATTERN}/o,
format: /json|yaml|sha256/
}
end
end
end
namespace :v1 do
resource :api_key, only: %i[show create update] do
collection do
post :revoke, to: "github_secret_scanning#revoke", defaults: { format: :json }
end
end
resource :multifactor_auth, only: :show
resource :webauthn_verification, only: :create do
get ':webauthn_token/status', action: :status, as: :status, constraints: { format: :json }
end
resources :profiles, only: :show
get "profile/me", to: "profiles#me"
resources :downloads, only: :index do
get :top, on: :collection
get :all, on: :collection
end
constraints id: Patterns::ROUTE_PATTERN, format: /json|yaml/ do
get 'owners/:handle/gems',
to: 'owners#gems',
as: 'owners_gems',
constraints: { handle: Patterns::ROUTE_PATTERN },
format: true
resources :downloads, only: :show, format: true
resources :versions, only: :show, format: true do
member do
get :reverse_dependencies, format: true
get 'latest',
to: 'versions#latest',
as: 'latest',
format: true,
constraints: { format: /json|js/ }
end
resources :downloads,
only: [:index],
controller: 'versions/downloads',
format: true do
collection do
get :search, format: true
end
end
end
end
resources :dependencies,
only: [:index],
format: /marshal|json/,
defaults: { format: 'marshal' }
# for handling preflight request
match '/gems/:id' => "rubygems#show", via: :options
resources :rubygems,
path: 'gems',
only: %i[create show index],
id: Patterns::LAZY_ROUTE_PATTERN,
format: /json|yaml/ do
member do
get :reverse_dependencies
end
collection do
delete :yank, to: "deletions#create"
end
constraints rubygem_id: Patterns::ROUTE_PATTERN do
resource :owners, only: %i[show create destroy]
end
end
resource :activity, only: [], format: /json|yaml/ do
collection do
get :latest
get :just_updated
end
end
resource :search, only: :show do
get :autocomplete
end
resources :web_hooks, only: %i[create index] do
collection do
delete :remove
post :fire
post :hook_relay_report, to: 'hook_relay#report', defaults: { format: :json }
end
end
resources :timeframe_versions, only: :index
namespace :oidc do
resources :api_key_roles, only: %i[index show], param: :token, format: 'json', defaults: { format: :json } do
member do
post :assume_role
end
end
resources :providers, only: %i[index show], format: 'json', defaults: { format: :json }
resources :id_tokens, only: %i[index show], format: 'json', defaults: { format: :json }
end
end
end
get '/versions' => 'api/compact_index#versions'
get '/info/:gem_name' => 'api/compact_index#info', as: :info,
constraints: { gem_name: Patterns::ROUTE_PATTERN }
get '/names' => 'api/compact_index#names'
################################################################################
# API v0
scope controller: 'api/deprecated', action: 'index' do
get 'api_key'
put 'api_key/reset'
put 'api/v1/gems/unyank'
put 'api/v1/api_key/reset'
post 'gems'
get 'gems/:id.json'
scope path: 'gems/:rubygem_id' do
put 'migrate'
post 'migrate'
end
end
################################################################################
# UI
scope constraints: { format: :html }, defaults: { format: 'html' } do
resource :search, only: :show do
get :advanced
end
resource :dashboard, only: :show, constraints: { format: /html|atom/ }
resources :profiles, only: :show
resource :multifactor_auth, only: %i[new create update destroy] do
get 'recovery'
post 'otp_update', to: 'multifactor_auths#otp_update', as: :otp_update
post 'webauthn_update', to: 'multifactor_auths#webauthn_update', as: :webauthn_update
end
resource :settings, only: :edit
resource :profile, only: %i[edit update] do
get :adoptions
member do
get :delete
delete :destroy, as: :destroy
end
resources :api_keys do
delete :reset, on: :collection
end
namespace :oidc do
resources :api_key_roles, param: :token do
member do
get 'github_actions_workflow'
end
end
resources :api_key_roles, param: :token, only: %i[show], constraints: { format: :json }
resources :id_tokens, only: %i[index show]
resources :providers, only: %i[index show]
end
end
resources :stats, only: :index
get "/news" => 'news#show', as: 'legacy_news_path'
resource :news, path: 'releases', only: [:show] do
get :popular, on: :collection
end
resource :notifier, only: %i[update show]
resources :rubygems,
only: %i[index show],
path: 'gems',
constraints: { id: Patterns::ROUTE_PATTERN, format: /html|atom/ } do
resource :subscription,
only: %i[create destroy],
constraints: { format: :js },
defaults: { format: :js }
resources :versions, only: %i[show index] do
get '/dependencies', to: 'dependencies#show', constraints: { format: /json|html/ }
end
resources :reverse_dependencies, only: %i[index]
resources :owners, only: %i[index destroy create], param: :handle do
get 'confirm', to: 'owners#confirm', as: :confirm, on: :collection
get 'resend_confirmation', to: 'owners#resend_confirmation', as: :resend_confirmation, on: :collection
end
resource :ownership_calls, only: %i[update create] do
patch 'close', to: 'ownership_calls#close', as: :close, on: :collection
end
resources :ownership_requests, only: %i[create update] do
patch 'close_all', to: 'ownership_requests#close_all', as: :close_all, on: :collection
end
resources :adoptions, only: %i[index]
end
resources :ownership_calls, only: :index
resources :webauthn_credentials, only: :destroy
resource :webauthn_verification, only: [] do
get 'successful_verification'
get 'failed_verification'
get ':webauthn_token', to: 'webauthn_verifications#prompt', as: ''
end
################################################################################
# Clearance Overrides and Additions
resource :email_confirmations, only: %i[new create] do
get 'confirm', to: 'email_confirmations#update', as: :update
post 'otp_update', to: 'email_confirmations#otp_update', as: :otp_update
post 'webauthn_update', to: 'email_confirmations#webauthn_update', as: :webauthn_update
patch 'unconfirmed'
end
resources :passwords, only: %i[new create]
resource :session, only: %i[create destroy] do
post 'otp_create', to: 'sessions#otp_create', as: :otp_create
post 'webauthn_create', to: 'sessions#webauthn_create', as: :webauthn_create
get 'verify', to: 'sessions#verify', as: :verify
post 'authenticate', to: 'sessions#authenticate', as: :authenticate
end
resources :users, only: %i[new create] do
resource :password, only: %i[create edit update] do
post 'otp_edit', to: 'passwords#otp_edit', as: :otp_edit
post 'webauthn_edit', to: 'passwords#webauthn_edit', as: :webauthn_edit
end
end
get '/sign_in' => 'sessions#new', as: 'sign_in'
delete '/sign_out' => 'sessions#destroy', as: 'sign_out'
get '/sign_up' => 'users#new', as: 'sign_up' if Clearance.configuration.allow_sign_up?
end
################################################################################
# UI API
scope constraints: { format: :json }, defaults: { format: :json } do
resources :webauthn_credentials, only: :create do
post :callback, on: :collection
end
end
scope constraints: { format: :text }, defaults: { format: :text } do
resource :webauthn_verification, only: [] do
post ':webauthn_token', to: 'webauthn_verifications#authenticate', as: :authenticate
end
end
################################################################################
# high_voltage static routes
get 'pages/*id' => 'high_voltage/pages#show', constraints: { id: /(#{HighVoltage.page_ids.join("|")})/ }, as: :page
################################################################################
# Internal Routes
namespace :internal do
get 'ping' => 'ping#index'
get 'revision' => 'ping#revision'
end
################################################################################
# Incoming Webhook Endpoint
resources :sendgrid_events, only: :create, format: false, defaults: { format: :json }
################################################################################
# Admin routes
constraints({ host: Gemcutter::SEPARATE_ADMIN_HOST }.compact) do
namespace :admin, constraints: { format: :html }, defaults: { format: 'html' } do
delete 'logout' => 'admin#logout', as: :logout
end
constraints(Constraints::Admin) do
namespace :admin, constraints: Constraints::Admin::RubygemsOrgAdmin do
mount GoodJob::Engine, at: 'good_job'
mount MaintenanceTasks::Engine, at: "maintenance_tasks"
end
mount Avo::Engine, at: Avo.configuration.root_path
end
end
scope :oauth, constraints: { format: :html }, defaults: { format: 'html' } do
get ':provider/callback', to: 'oauth#create'
get 'failure', to: 'oauth#failure'
get 'development_log_in_as/:admin_github_user_id', to: 'oauth#development_log_in_as' if Gemcutter::ENABLE_DEVELOPMENT_ADMIN_LOG_IN
end
################################################################################
# Development routes
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
end