Merge branch '21743-users-include-trash'
[arvados.git] / services / api / config / routes.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 Rails.application.routes.draw do
6   # OPTIONS requests are not allowed at routes that use cookies.
7   ['/auth/*a', '/login', '/logout'].each do |nono|
8     match nono, to: 'user_sessions#cross_origin_forbidden', via: 'OPTIONS'
9   end
10   # OPTIONS at discovery and API paths get an empty response with CORS headers.
11   match '/discovery/v1/*a', to: 'static#empty', via: 'OPTIONS'
12   match '/arvados/v1/*a', to: 'static#empty', via: 'OPTIONS'
13
14   namespace :arvados do
15     namespace :v1 do
16       resources :api_client_authorizations do
17         post 'create_system_auth', on: :collection
18         get 'current', on: :collection
19       end
20       resources :authorized_keys
21       resources :collections do
22         get 'provenance', on: :member
23         get 'used_by', on: :member
24         post 'trash', on: :member
25         post 'untrash', on: :member
26       end
27       resources :groups do
28         get 'contents', on: :collection
29         get 'contents', on: :member
30         get 'shared', on: :collection
31         post 'trash', on: :member
32         post 'untrash', on: :member
33       end
34       resources :containers do
35         get 'auth', on: :member
36         post 'lock', on: :member
37         post 'unlock', on: :member
38         post 'update_priority', on: :member
39         get 'secret_mounts', on: :member
40         get 'current', on: :collection
41       end
42       resources :container_requests do
43         get 'container_status', on: :member
44       end
45       resources :keep_services do
46         get 'accessible', on: :collection
47       end
48       resources :links
49       resources :logs
50       resources :user_agreements do
51         get 'signatures', on: :collection
52         post 'sign', on: :collection
53       end
54       resources :users do
55         get 'current', on: :collection
56         get 'system', on: :collection
57         post 'activate', on: :member
58         post 'setup', on: :collection
59         post 'unsetup', on: :member
60         post 'merge', on: :collection
61         patch 'batch_update', on: :collection
62       end
63       resources :virtual_machines do
64         get 'logins', on: :member
65         get 'get_all_logins', on: :collection
66       end
67       resources :workflows
68       get '/computed_permissions', to: 'computed_permissions#index'
69       get '/permissions/:uuid', to: 'links#get_permissions'
70     end
71   end
72
73   post '/sys/trash_sweep', to: 'sys#trash_sweep'
74
75   if Rails.env == 'test'
76     post '/database/reset', to: 'database#reset'
77   end
78
79   # omniauth
80   match '/auth/:provider/callback', to: 'user_sessions#create', via: [:get, :post]
81   match '/auth/failure', to: 'user_sessions#failure', via: [:get, :post]
82   # not handled by omniauth provider -> 403 with no CORS headers.
83   get '/auth/*a', to: 'user_sessions#cross_origin_forbidden'
84
85   # Custom logout
86   match '/login', to: 'user_sessions#login', via: [:get, :post]
87   match '/logout', to: 'user_sessions#logout', via: [:get, :post]
88
89   match '/discovery/v1/apis/arvados/v1/rest', to: 'arvados/v1/schema#index', via: [:get, :post]
90
91   match '/static/login_failure', to: 'static#login_failure', as: :login_failure, via: [:get, :post]
92
93   match '/_health/:check', to: 'arvados/v1/management#health', via: [:get]
94   match '/metrics', to: 'arvados/v1/management#metrics', via: [:get]
95
96   # Send unroutable requests to an arbitrary controller
97   # (ends up at ApplicationController#render_not_found)
98   match '*a', to: 'static#render_not_found', via: [:get, :post, :put, :patch, :delete, :options]
99
100   root to: 'static#home'
101 end