Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused sys actions #17048

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 1 addition & 87 deletions app/controllers/sys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,46 +33,6 @@ class SysController < ActionController::Base

before_action :check_enabled
before_action :require_basic_auth, only: [:repo_auth]
before_action :find_project, only: [:update_required_storage]
before_action :find_repository_with_storage, only: [:update_required_storage]

def projects
p = Project.active.has_module(:repository)
.includes(:repository)
.references(:repositories)
.order(Arel.sql("identifier"))
respond_to do |format|
format.json do
render json: p.to_json(include: :repository)
end
format.any(:html, :xml) do
render xml: p.to_xml(include: :repository), content_type: Mime[:xml]
end
end
end

def update_required_storage
result = update_storage_information(@repository, params[:force] == "1")
render plain: "Updated: #{result}", status: :ok
end

def fetch_changesets
projects = []
if params[:id]
projects << Project.active.has_module(:repository).find_by!(identifier: params[:id])
else
projects = Project.active.has_module(:repository)
.includes(:repository).references(:repositories)
end
projects.each do |project|
if project.repository
project.repository.fetch_changesets
end
end
head :ok
rescue ActiveRecord::RecordNotFound
head :not_found
end

def repo_auth
project = Project.find_by(identifier: params[:repository])
Expand Down Expand Up @@ -104,38 +64,9 @@ def check_enabled
end
end

def update_storage_information(repository, force = false)
if force
::SCM::StorageUpdaterJob.perform_later(repository)
true
else
repository.update_required_storage
end
end

def find_project
@project = Project.find(params[:id])
rescue ActiveRecord::RecordNotFound
render plain: "Could not find project ##{params[:id]}.", status: :not_found
end

def find_repository_with_storage
@repository = @project.repository

if @repository.nil?
render plain: "Project ##{@project.id} does not have a repository.", status: :not_found
else
return true if @repository.scm.storage_available?

render plain: "repositories.storage.not_available", status: :bad_request
end

false
end

def require_basic_auth
authenticate_with_http_basic do |username, password|
@authenticated_user = cached_user_login(username, password)
@authenticated_user = user_login(username, password)
return true if @authenticated_user
end

Expand All @@ -147,21 +78,4 @@ def require_basic_auth
def user_login(username, password)
User.try_to_login(username, password)
end

def cached_user_login(username, password)
unless Setting.repository_authentication_caching_enabled?
return user_login(username, password)
end

user = nil
user_id = Rails.cache.fetch(OpenProject::RepositoryAuthentication::CACHE_PREFIX + Digest::SHA1.hexdigest("#{username}#{password}"),
expires_in: OpenProject::RepositoryAuthentication::CACHE_EXPIRES_AFTER) do
user = user_login(username, password)
user ? user.id.to_s : "-1"
end

return nil if user_id.blank? or user_id == "-1"

user || User.find_by(id: user_id.to_i)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ See COPYRIGHT and LICENSE files for more details.
</div>
<div class="form--field"><%= setting_text_field :repository_log_display_limit, size: 6, container_class: '-xslim' %></div>
<div class="form--field"><%= setting_text_field :repository_truncate_at, size: 6, container_class: '-xslim' %></div>
<div class="form--field"><%= setting_check_box :repository_authentication_caching_enabled %></div>
</section>
<%= render partial: 'repositories_checkout' %>
<fieldset class="form--fieldset">
Expand Down
3 changes: 0 additions & 3 deletions config/constants/settings/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,6 @@ class Definition
default: nil,
format: :string
},
repository_authentication_caching_enabled: {
default: true
},
repository_checkout_data: {
default: {
"git" => { "enabled" => 0 },
Expand Down
1 change: 0 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3412,7 +3412,6 @@ en:
setting_registration_footer: "Registration footer"
setting_repositories_automatic_managed_vendor: "Automatic repository vendor type"
setting_repositories_encodings: "Repositories encodings"
setting_repository_authentication_caching_enabled: "Enable caching for authentication request of version control software"
setting_repository_storage_cache_minutes: "Repository disk size cache"
setting_repository_checkout_display: "Show checkout instructions"
setting_repository_checkout_base_url: "Checkout base URL"
Expand Down
6 changes: 3 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,9 @@

scope controller: "sys" do
match "/sys/repo_auth", action: "repo_auth", via: %i[get post]
get "/sys/projects", action: "projects"
get "/sys/fetch_changesets", action: "fetch_changesets"
get "/sys/projects/:id/repository/update_storage", action: "update_required_storage"
match "/sys/projects", to: proc { [410, {}, [""]] }, via: :all
match "/sys/fetch_changesets", to: proc { [410, {}, [""]] }, via: :all
match "/sys/projects/:id/repository/update_storage", to: proc { [410, {}, [""]] }, via: :all
end

# alternate routes for the current user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ The total required disk space for a project's its repository and attachments are

This information is refreshed in the same manner that changesets are retrieved: By default, the repository is refreshed when a user visits the repository page. This information is cached for the time configured under the global `administration settings → repositories`.

It could also externally be refreshed by using a cron job using the Sys API. Executing a GET against `/sys/projects/:identifier/repository/update_storage` will cause a refresh when the maximum cache time is expired. If you pass the query `?force=1` to the request above, it will ignore the cache.

For a future release, we are hoping to provide a webhook to update changesets and storage immediately after a change has been committed to the repository.

## Accessing repositories through Apache

With managed repositories, OpenProject takes care of the lifetime of repositories and their association with projects, however we still need to serve the repositories to the client.
Expand Down
52 changes: 0 additions & 52 deletions extra/svn/reposman.rb

This file was deleted.

2 changes: 0 additions & 2 deletions modules/backlogs/app/controllers/rb_application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class RbApplicationController < ApplicationController

before_action :load_sprint_and_project, :check_if_plugin_is_configured, :authorize

skip_before_action :verify_authenticity_token, if: -> { Rails.env.test? }

# Use special backlogs layout to initialize stimulus side-loading legacy backlogs scripts
# and CSS from frontend
layout "backlogs"
Expand Down
Loading
Loading