Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Delete the cached token in case of a 403

Marcello Rochaa2eb1bcc44f0
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_client_credentials.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_client_credentials.rb
index 2c5c7dc7e1c..9d041f1c315 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_client_credentials.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_client_credentials.rb
@@ -64,6 +64,8 @@ module Storages
if access_token.nil? && operation_result.success?
token = http.instance_variable_get(:@options).oauth_session.access_token
Rails.cache.write("storage.#{storage.id}.httpx_access_token", token, expires_in: 50.minutes)
+ elsif operation_result.failure? && operation_result.result == :forbidden
+ Rails.cache.delete("storage.#{storage.id}.httpx_access_token")
end
operation_result