Skip to content

Commit

Permalink
lint a random file (#3447)
Browse files Browse the repository at this point in the history
  • Loading branch information
osc-bot authored Mar 22, 2024
1 parent 3ff3552 commit 0cd6c64
Showing 1 changed file with 40 additions and 38 deletions.
78 changes: 40 additions & 38 deletions apps/dashboard/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require "authz/app_developer_constraint"
# frozen_string_literal: true

Rails.application.routes.draw do
require 'authz/app_developer_constraint'

Rails.application.routes.draw do
if Configuration.can_access_projects?
resources :projects do
root 'projects#index'
Expand All @@ -12,59 +13,60 @@
end
end


# in production, if the user doesn't have access to the files app directory, we hide the routes
if Configuration.can_access_files?
constraints(lambda { |request| request.params[:fs].to_s.match?(/^(?!(edit|api))[^\/]+$/) }) do
get "files/:fs(/*filepath)" => "files#fs", :defaults => { :fs => 'fs', :format => 'html' }, :format => false, as: :files
put "files/:fs/*filepath" => "files#update", :format => false, :defaults => { :fs => 'fs', :format => 'json' }
constraints(->(request) { request.params[:fs].to_s.match?(%r{^(?!(edit|api))[^/]+$}) }) do
get 'files/:fs(/*filepath)' => 'files#fs', :defaults => { :fs => 'fs', :format => 'html' }, :format => false,
:as => :files
put 'files/:fs/*filepath' => 'files#update', :format => false, :defaults => { :fs => 'fs', :format => 'json' }

# TODO: deprecate these routes after updating OodAppkit to use the new routes above
# backwards compatibility with the "api" routes that OodAppkit provides
# and are used by File Editor and Job Composer
get "files/api/v1/:fs(/*filepath)" => "files#fs", :defaults => { :fs => 'fs', :format => 'html' }, :format => false
put "files/api/v1/:fs/*filepath" => "files#update", :format => false, :defaults => { :fs => 'fs', :format => 'json' }
get 'files/api/v1/:fs(/*filepath)' => 'files#fs', :defaults => { :fs => 'fs', :format => 'html' },
:format => false
put 'files/api/v1/:fs/*filepath' => 'files#update', :format => false,
:defaults => { :fs => 'fs', :format => 'json' }
end
post "files/upload/:fs" => "files#upload", :defaults => { :fs => 'fs' } if Configuration.upload_enabled?
post 'files/upload/:fs' => 'files#upload', :defaults => { :fs => 'fs' } if Configuration.upload_enabled?

get "files", to: redirect("files/fs#{Dir.home}")
get 'files', to: redirect("files/fs#{Dir.home}")
get 'files/fs', to: redirect("files/fs#{Dir.home}")

resources :transfers, only: [:show, :create, :destroy]
end

if Configuration.can_access_file_editor?
if Configuration.can_access_file_editor?
# App file editor
get "files/edit/:fs/*filepath" => "files#edit", defaults: { :fs => 'fs', :path => "/" , :format => 'html' }, format: false
get "files/edit/:fs" => "files#edit", :defaults => { :fs => 'fs', :path => "/", :format => 'html' }, format: false
get 'files/edit/:fs/*filepath' => 'files#edit', :defaults => { :fs => 'fs', :path => '/', :format => 'html' },
:format => false
get 'files/edit/:fs' => 'files#edit', :defaults => { :fs => 'fs', :path => '/', :format => 'html' },
:format => false
end

namespace :batch_connect do
resources :sessions, only: [:index, :destroy]
post "sessions/:id/cancel", to: "sessions#cancel", as: 'cancel_session'
scope "*token", constraints: { token: /((usr\/[^\/]+)|dev|sys)\/[^\/]+(\/[^\/]+)?/ } do
post 'sessions/:id/cancel', to: 'sessions#cancel', as: 'cancel_session'
scope '*token', constraints: { token: %r{((usr/[^/]+)|dev|sys)/[^/]+(/[^/]+)?} } do
resources :session_contexts, only: [:new, :create]
root "session_contexts#new"
root 'session_contexts#new'
end
end
get "errors/not_found"
get "errors/internal_server_error"
get "dashboard/index"
get "logout" => "dashboard#logout"
get 'errors/not_found'
get 'errors/internal_server_error'
get 'dashboard/index'
get 'logout' => 'dashboard#logout'

# analytics request appears in the access logs and google analytics
get "analytics/:type" => proc { [204, {}, ['']] }, as: "analytics"
get 'analytics/:type' => proc { [204, {}, ['']] }, :as => 'analytics'

get 'apps/show/:name(/:type(/:owner))' => 'apps#show', :as => 'app', :defaults => { type: 'sys' }
get 'apps/icon/:name(/:type(/:owner))' => 'apps#icon', :as => 'app_icon', :defaults => { type: 'sys' }
get 'apps/index' => 'apps#index'

get "apps/show/:name(/:type(/:owner))" => "apps#show", as: "app", defaults: { type: "sys" }
get "apps/icon/:name(/:type(/:owner))" => "apps#icon", as: "app_icon", defaults: { type: "sys" }
get "apps/index" => "apps#index"

if Configuration.app_sharing_enabled?
get "apps/restart" => "apps#restart"
end
get 'apps/restart' => 'apps#restart' if Configuration.app_sharing_enabled?

root "dashboard#index"
root 'dashboard#index'

# App administration
scope 'admin/:type', constraints: Authz::AppDeveloperConstraint do
Expand All @@ -87,26 +89,26 @@

# ActiveJobs which can be disabled in production
if Configuration.can_access_activejobs?
get "/activejobs" => "active_jobs#index"
get "/activejobs/json" => "active_jobs#json", :defaults => { :format => 'json' }
delete "/activejobs" => "active_jobs#delete_job", as: 'delete_job'
get '/activejobs' => 'active_jobs#index'
get '/activejobs/json' => 'active_jobs#json', :defaults => { :format => 'json' }
delete '/activejobs' => 'active_jobs#delete_job', :as => 'delete_job'
end

get '/jobs/info/:cluster/:id' => 'jobs#info', :defaults => { :format => 'json' }, :as => 'jobs_info'

post "settings", :to => "settings#update"
post 'settings', :to => 'settings#update'

# Support ticket routes
if Configuration.support_ticket_enabled?
get "/support", to: "support_ticket#new"
post "/support", to: "support_ticket#create"
get '/support', to: 'support_ticket#new'
post '/support', to: 'support_ticket#create'
end

# Custom pages route
get "/custom/:page_code", to: "custom_pages#index", as: :custom_pages
get '/custom/:page_code', to: 'custom_pages#index', as: :custom_pages

match "/404", :to => "errors#not_found", :via => :all
match "/500", :to => "errors#internal_server_error", :via => :all
match '/404', :to => 'errors#not_found', :via => :all
match '/500', :to => 'errors#internal_server_error', :via => :all

# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
Expand Down

0 comments on commit 0cd6c64

Please sign in to comment.