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