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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#62107] Reacto on PR comments.
Pavel Balashou19d76423349b
diff --git a/app/contracts/groups/base_contract.rb b/app/contracts/groups/base_contract.rbindex 9f5f436c051..16a0970a191 100644--- a/app/contracts/groups/base_contract.rb+++ b/app/contracts/groups/base_contract.rb@@ -37,7 +37,6 @@ module Groups# hence we need to put "lastname" as an attribute hereattribute :nameattribute :lastname- attribute :identity_urlvalidate :validate_unique_usersdiff --git a/app/contracts/users/delete_contract.rb b/app/contracts/users/delete_contract.rbindex f76eb13837e..cf3d5178e1e 100644--- a/app/contracts/users/delete_contract.rb+++ b/app/contracts/users/delete_contract.rb@@ -43,8 +43,7 @@ module Usersif actor == userSetting.users_deletable_by_self?else- (actor.admin? && actor.active? && Setting.users_deletable_by_admins?) ||- User.system == actor+ actor.admin? && actor.active? && Setting.users_deletable_by_admins?endendenddiff --git a/app/controllers/scim_v2/scim_controller_mixins.rb b/app/controllers/scim_v2/scim_controller_mixins.rbindex 5a160ce334c..d44942eaf02 100644--- a/app/controllers/scim_v2/scim_controller_mixins.rb+++ b/app/controllers/scim_v2/scim_controller_mixins.rb@@ -40,11 +40,10 @@ module ScimV2return handle_scim_error(Scimitar::AuthenticationError.new) unless OpenProject::FeatureDecisions.scim_api_active?warden = request.env["warden"]- User.current = warden.authenticate! scope: :scim_v2+ User.current = warden.authenticate!(scope: :scim_v2)# Only a ServiceAccount associated with a ScimClient can use SCIM Server API-- unless User.current.is_a?(ServiceAccount) && User.current.service_account_association.service.is_a?(ScimClient)+ unless User.current.respond_to?(:service) && User.current.service.is_a?(ScimClient)handle_scim_error(Scimitar::AuthenticationError.new)endenddiff --git a/app/controllers/scim_v2/users_controller.rb b/app/controllers/scim_v2/users_controller.rbindex 288b37a2491..e211be004b1 100644--- a/app/controllers/scim_v2/users_controller.rb+++ b/app/controllers/scim_v2/users_controller.rb@@ -114,8 +114,6 @@ module ScimV2elseraise result.messageend-- raise call.messageendendenddiff --git a/app/models/principal.rb b/app/models/principal.rbindex 3db8f0429b8..5e10900f000 100644--- a/app/models/principal.rb+++ b/app/models/principal.rb@@ -239,19 +239,19 @@ class Principal < ApplicationRecordexternal_idend- def self.scim_mutable_attributes- # Allow mutation of everything with a write accessor- nil- end+ class << self+ def scim_mutable_attributes+ # Allow mutation of everything with a write accessor+ nil+ end- def self.scim_timestamps_map- {- created: :created_at,- lastModified: :updated_at- }- end+ def scim_timestamps_map+ {+ created: :created_at,+ lastModified: :updated_at+ }+ end- class << self# Hack to exclude the Users::InexistentUser# from showing up on filters for type.# The method is copied over from rails changed onlydiff --git a/app/models/service_account.rb b/app/models/service_account.rbindex 2048e2b318b..2a17c0e1a74 100644--- a/app/models/service_account.rb+++ b/app/models/service_account.rb@@ -35,6 +35,8 @@ class ServiceAccount < Userhas_one :service_account_association, dependent: :destroy+ delegate :service, to: :service_account_association+def to_snameenddiff --git a/app/services/authentication/omniauth_service.rb b/app/services/authentication/omniauth_service.rbindex a59214962d9..b48d154bba1 100644--- a/app/services/authentication/omniauth_service.rb+++ b/app/services/authentication/omniauth_service.rb@@ -168,7 +168,12 @@ module Authenticationif developer_provider?User.find_by(mail: auth_hash[:uid])else- UserAuthProviderLink.with_identity_url(user_attributes[:identity_url]).first&.principal+ UserAuthProviderLink+ .left_joins(:principal)+ .where(principal: { type: "User" })+ .with_identity_url(user_attributes[:identity_url])+ .first+ &.principalendenddiff --git a/app/services/user_auth_provider_links_setter.rb b/app/services/user_auth_provider_links_setter.rbindex 7fdd3280b47..5082b0ca297 100644--- a/app/services/user_auth_provider_links_setter.rb+++ b/app/services/user_auth_provider_links_setter.rb@@ -46,7 +46,7 @@ module UserAuthProviderLinksSettermodel.user_auth_provider_links.find { |l| l.id == link.id }.external_id_will_change!endelse- raise ActiveRecord::RecordNotFound, "AuthProvider with slug: \"#{slug}\" has been not found"+ raise ActiveRecord::RecordNotFound, "AuthProvider with slug: \"#{slug}\" has not been found"endendenddiff --git a/config/initializers/warden.rb b/config/initializers/warden.rbindex 96da619d4c5..a21a7bd1291 100644--- a/config/initializers/warden.rb+++ b/config/initializers/warden.rb@@ -27,7 +27,7 @@ OpenProject::Authentication.update_strategies(OpenProject::Authentication::ScopeendOpenProject::Authentication.update_strategies(OpenProject::Authentication::Scope::SCIM_V2, { store: false }) do |_|- %i[oauth jwt_oidc session]+ %i[oauth jwt_oidc]endRails.application.configure do |app|diff --git a/lib_static/open_project/authentication/strategies/warden/doorkeeper_oauth.rb b/lib_static/open_project/authentication/strategies/warden/doorkeeper_oauth.rbindex 7a690b9e7cf..dc7e1e4b6de 100644--- a/lib_static/open_project/authentication/strategies/warden/doorkeeper_oauth.rb+++ b/lib_static/open_project/authentication/strategies/warden/doorkeeper_oauth.rb@@ -42,7 +42,8 @@ module OpenProjectenddef authenticate_user(id)- user = id && User.active.where(id:).or(ServiceAccount.where(id:)).first+ # ServiceAccount is found explicitly because ServiceAccount is builtin, but User.active excludes builtin entities.+ user = id && User.active.where(id:).or(ServiceAccount.where(id:, status: ServiceAccount.statuses[:active])).firstif usersuccess!(user)elsediff --git a/lib_static/open_project/authentication/strategies/warden/jwt_oidc.rb b/lib_static/open_project/authentication/strategies/warden/jwt_oidc.rbindex 35ebbb5a130..f6991bd137d 100644--- a/lib_static/open_project/authentication/strategies/warden/jwt_oidc.rb+++ b/lib_static/open_project/authentication/strategies/warden/jwt_oidc.rb@@ -30,7 +30,11 @@ module OpenProjecterror_description: "Requires scope #{scope} to access this resource."end- user = provider.user_auth_provider_links.find_by(external_id: payload["sub"])&.principal+ user = provider+ .user_auth_provider_links+ .left_joins(:principal)+ .where(principal: { type: ["User", "ServiceAccount"] })+ .find_by(external_id: payload["sub"])&.principalauthentication_result(user)end,->(error) { fail_with_header!(error: "invalid_token", error_description: error) }