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
[#63912] React on PR comments.
Pavel Balashou83794a74663b
diff --git a/app/contracts/users/base_contract.rb b/app/contracts/users/base_contract.rbindex 2a19ecc3deb..70d38278d5e 100644--- a/app/contracts/users/base_contract.rb+++ b/app/contracts/users/base_contract.rb@@ -62,6 +62,9 @@ module Usersdef reduce_writable_attributes(attributes)super.tap do |writable|+ # `password` and `identity_url` are not regular attributes so they bypass+ # attribute writable checks. therewore they must be added to the list+ # of writable attributes under certain conditions.writable << "password" if password_writable?writable << "identity_url" if identity_url_writable?end@@ -69,9 +72,6 @@ module Usersprivate- ##- # Password is not a regular attribute so it bypasses- # attribute writable checksdef password_writable?user.admin? || user.id == model.idenddiff --git a/app/controllers/concerns/user_invitation.rb b/app/controllers/concerns/user_invitation.rbindex f2e8076f010..b11137b4038 100644--- a/app/controllers/concerns/user_invitation.rb+++ b/app/controllers/concerns/user_invitation.rb@@ -103,7 +103,7 @@ module UserInvitationenddef reset_login(user_id)- UserAuthProviderLink.where(user_id:).destroy_all+ UserAuthProviderLink.where(user_id:).delete_allUserPassword.where(user_id:).destroy_allenddiff --git a/app/models/auth_provider.rb b/app/models/auth_provider.rbindex 1070da838fd..6b93ece9382 100644--- a/app/models/auth_provider.rb+++ b/app/models/auth_provider.rb@@ -30,6 +30,7 @@ class AuthProvider < ApplicationRecordbelongs_to :creator, class_name: "User"has_many :user_auth_provider_links, dependent: :destroy+ has_many :users, through: :user_auth_provider_linksvalidates :display_name, presence: truevalidates :display_name, uniqueness: true@@ -57,10 +58,6 @@ class AuthProvider < ApplicationRecordURI.join(auth_url, "callback").to_send- def to_s- slug- end-protecteddef unset_direct_providerdiff --git a/app/models/user.rb b/app/models/user.rbindex 0bdae4df2cd..dc09e8cd937 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -97,6 +97,7 @@ class User < Principalhas_many :reminders, foreign_key: "creator_id", dependent: :destroy, inverse_of: :creatorhas_many :remote_identities, dependent: :destroyhas_many :user_auth_provider_links, dependent: :destroy+ has_many :auth_providers, through: :user_auth_provider_links# Users blocked via brute force prevention# use lambda here, so time is evaluated on each query@@ -110,6 +111,8 @@ class User < Principal:with_time_zone,:having_reminder_mail_to_send+ self.ignored_columns += [:identity_url]+def self.create_blocked_scope(scope, blocked)scope.where(blocked_condition(blocked))enddiff --git a/app/services/authentication/omniauth_service.rb b/app/services/authentication/omniauth_service.rbindex afd703eac6b..5faf0209595 100644--- a/app/services/authentication/omniauth_service.rb+++ b/app/services/authentication/omniauth_service.rb@@ -37,7 +37,6 @@ module Authentication:controller,:contract,:user_attributes,- :identity_url,:userdelegate :session, to: :controller@@ -122,7 +121,6 @@ module Authenticationdef update_user_from_omniauth!(additional_user_params)# Find or create the user from the auth hashself.user_attributes = build_omniauth_hash_to_user_attributes.merge(additional_user_params)- self.identity_url = user_attributes[:identity_url]self.user = lookup_or_initialize_user# Assign or update the user with the omniauth attributes@@ -153,8 +151,8 @@ module Authenticationreturn unless tokentoken.user.tap do |user|- if identity_url.present?- slug, external_id = identity_url.split(":", 2)+ if user_attributes[:identity_url].present?+ slug, external_id = user_attributes[:identity_url].split(":", 2)link = user.user_auth_provider_links.find_or_initialize_by(auth_provider: AuthProvider.find_by!(slug:))link.external_id = external_idlink.save!@@ -170,7 +168,7 @@ module Authenticationif developer_provider?User.find_by(mail: auth_hash[:uid])else- UserAuthProviderLink.with_identity_url(identity_url).first&.user+ UserAuthProviderLink.with_identity_url(user_attributes[:identity_url]).first&.userendend@@ -294,7 +292,7 @@ module Authentication# Indicates whether OmniAuth::Strategies::Delevoper strategy is used.# https://github.com/omniauth/omniauth/blob/0bcfd5b25bf946422cd4d9c40c4f514121ac04d6/lib/omniauth/strategies/developer.rb# if true:- # identity_url should no be set i+ # identity_url should not be set and# user should be found by mail, because mail plays uid role in developer strategydef developer_provider?Rails.env.local? && auth_hash[:provider] == "developer"diff --git a/db/migrate/20250512114003_move_users_identity_url_to_user_auth_provider_links.rb b/db/migrate/20250512114003_move_users_identity_url_to_user_auth_provider_links.rbindex 64705083537..1e492080c24 100644--- a/db/migrate/20250512114003_move_users_identity_url_to_user_auth_provider_links.rb+++ b/db/migrate/20250512114003_move_users_identity_url_to_user_auth_provider_links.rb@@ -36,6 +36,7 @@ class MoveUsersIdentityUrlToUserAuthProviderLinks < ActiveRecord::Migration[8.0]t.string :external_id, null: falset.timestamps null: falset.index %i[user_id auth_provider_id], unique: true+ t.index %i[auth_provider_id external_id], unique: trueendreversible do |direction|@@ -67,6 +68,5 @@ class MoveUsersIdentityUrlToUserAuthProviderLinks < ActiveRecord::Migration[8.0]endendend- remove_column :users, :identity_url, :stringendenddiff --git a/docs/api/apiv3/components/schemas/user_model.yml b/docs/api/apiv3/components/schemas/user_model.ymlindex 1ebbe6ebf5f..b5a8286ca84 100644--- a/docs/api/apiv3/components/schemas/user_model.yml+++ b/docs/api/apiv3/components/schemas/user_model.yml@@ -83,7 +83,7 @@ allOf:- 'null'description: |-User's identity_url for OmniAuth authentication.- **Deprecated:** It will be removed in the near future. Use `UserAuthProviderLink` API instead.+ **Deprecated:** It will be removed in the near future.# Conditionsdiff --git a/lib_static/open_project/authentication/strategies/warden/jwt_oidc.rb b/lib_static/open_project/authentication/strategies/warden/jwt_oidc.rbindex fb17558f8e0..1088aa1c0c6 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,7 @@ module OpenProjecterror_description: "Requires scope #{scope} to access this resource."end- user = UserAuthProviderLink.where(auth_provider: provider, external_id: payload["sub"]).first&.user+ user = provider.user_auth_provider_links.find_by(external_id: payload["sub"])&.userauthentication_result(user)end,->(error) { fail_with_header!(error: "invalid_token", error_description: error) }diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rbindex 57bf0644b6f..cab39ac30b1 100644--- a/spec/factories/user_factory.rb+++ b/spec/factories/user_factory.rb@@ -73,9 +73,7 @@ FactoryBot.define doraise "slug or external_id is blank" if slug.blank? || external_id.blank?auth_provider = AuthProvider.find_by(slug:) || create(:oidc_provider, slug:)- user.user_auth_provider_links.create!(auth_provider:,- external_id: external_id)-+ user.user_auth_provider_links.create!(auth_provider:, external_id:)endend