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
[#66434] Update scimitar.
Pavel Balashou47049c156ef7
diff --git a/Gemfile b/Gemfileindex e29497d5d3e..19e2f8c3c2c 100644--- a/Gemfile+++ b/Gemfile@@ -59,7 +59,7 @@ gem "will_paginate", "~> 4.0.0"gem "friendly_id", "~> 5.5.0"-gem "scimitar", "~> 2.11"+gem "scimitar", "~> 2.12"gem "acts_as_list", "~> 1.2.0"gem "acts_as_tree", "~> 2.9.0"diff --git a/Gemfile.lock b/Gemfile.lockindex d28ebe89689..61b681d4979 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -1157,7 +1157,7 @@ GEMsanitize (7.0.0)crass (~> 1.0.2)nokogiri (>= 1.16.8)- scimitar (2.11.0)+ scimitar (2.12.0)rails (>= 7.0)securerandom (0.4.1)selenium-devtools (0.138.0)@@ -1502,7 +1502,7 @@ DEPENDENCIESruby-progressbar (~> 1.13.0)rubytree (~> 2.1.0)sanitize (~> 7.0.0)- scimitar (~> 2.11)+ scimitar (~> 2.12)selenium-devtoolsselenium-webdriver (~> 4.20)semantic (~> 1.6.1)@@ -1931,7 +1931,7 @@ CHECKSUMSrubyzip (2.3.2) sha256=3f57e3935dc2255c414484fbf8d673b4909d8a6a57007ed754dde39342d2373fsafety_net_attestation (0.4.0) sha256=96be2d74e7ed26453a51894913449bea0e072f44490021545ac2d1c38b0718cesanitize (7.0.0) sha256=269d1b9d7326e69307723af5643ec032ff86ad616e72a3b36d301ac75a273984- scimitar (2.11.0) sha256=77cf779a843be7d572046acdcf0a1829bd3b1c33db993fa83faf7f1863d8c625+ scimitar (2.12.0) sha256=a6062aef5217d8868b6fe96b8769521f0e79de374813c44bebc72d13b95616f5securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1selenium-devtools (0.138.0) sha256=596c08e114342dd89513bc3d18bbb2ae39e532864dbc25c09a48fb9922fc5b7bselenium-webdriver (4.34.0) sha256=ec7bb718cbe66fe2b247d8ca5e6ba26caed0976d76579d7cb2fadd8dae8b271ediff --git a/app/controllers/scim_v2/scim_controller_mixins.rb b/app/controllers/scim_v2/scim_controller_mixins.rbdeleted file mode 100644index adbeecd0f5c..00000000000--- a/app/controllers/scim_v2/scim_controller_mixins.rb+++ /dev/null@@ -1,95 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--module ScimV2- module ScimControllerMixins- module ApplicationControllerMixin- def self.included(base)- base.prepend(Overwrites)- end-- module Overwrites- # Completely overwriting authenticate method of Scimitar- def authenticate- if !EnterpriseToken.allows_to?(:scim_api) || !OpenProject::FeatureDecisions.scim_api_active?- return handle_scim_error(Scimitar::AuthenticationError.new)- end-- user = warden.authenticate(scope: :scim_v2)- if user == nil- throw(:warden) unless available_publically?- else- User.current = user- # Only a ServiceAccount associated with a ScimClient can use SCIM Server API- unless User.current.respond_to?(:service) && User.current.service.is_a?(ScimClient)- handle_scim_error(Scimitar::AuthenticationError.new)- end- end- end-- def available_publically?- false- end-- private-- def warden- request.env["warden"]- end- end- end-- module ServiceProviderConfigurationControllerMixin- def self.included(base)- base.prepend(Overwrites)- end-- module Overwrites- def show- if User.current == User.anonymous- if warden.winning_strategy.blank? # it means authorization header was absent. So, there is no appropriate strategy- render json: ScimitarSchemaExtension::LimitedServiceProviderConfiguration.new- else- throw(:warden)- end- else- super- end- end-- private-- def available_publically?- true- end- end- end- end-enddiff --git a/config/initializers/scimitar.rb b/config/initializers/scimitar.rbindex 47ec8a89c72..de092a6efe2 100644--- a/config/initializers/scimitar.rb+++ b/config/initializers/scimitar.rb@@ -31,21 +31,41 @@Rails.application.config.to_prepare doScimitar.service_provider_configuration = Scimitar::ServiceProviderConfiguration.new(patch: Scimitar::Supportable.supported,- authenticationSchemes: ScimitarSchemaExtension::AUTHENTICATION_SCHEMES+ authenticationSchemes: OpenProjectScimitar::AUTHENTICATION_SCHEMES)Scimitar.engine_configuration = Scimitar::EngineConfiguration.new(- application_controller_mixin: ScimV2::ScimControllerMixins::ApplicationControllerMixin- )+ custom_authenticator: lambda do+ if !EnterpriseToken.allows_to?(:scim_api) || !OpenProject::FeatureDecisions.scim_api_active?+ return handle_scim_error(Scimitar::AuthenticationError.new)+ end- Scimitar::ServiceProviderConfigurationsController.include(- ScimV2::ScimControllerMixins::ServiceProviderConfigurationControllerMixin+ warden = request.env["warden"]+ user = warden.authenticate(scope: :scim_v2)+ if user == nil+ if controller_path != "scimitar/service_provider_configurations" ||+ # it means authorization credentials were provided in ways expexcted by OpenProject, but the credentials were wrong. So, no user found.+ warden.winning_strategy.present?+ throw(:warden)+ else+ render json: OpenProjectScimitar::LimitedServiceProviderConfiguration.new+ return+ end+ else+ User.current = user+ # Only a ServiceAccount associated with a ScimClient can use SCIM Server API+ unless User.current.respond_to?(:service) && User.current.service.is_a?(ScimClient)+ return handle_scim_error(Scimitar::AuthenticationError.new)+ end+ end+ true+ end)Scimitar::Schema::User.singleton_class.class_eval do- prepend ScimitarSchemaExtension::User+ prepend OpenProjectScimitar::UserendScimitar::Schema::Group.singleton_class.class_eval do- prepend ScimitarSchemaExtension::Group+ prepend OpenProjectScimitar::Groupendenddiff --git a/lib/open_project_scimitar.rb b/lib/open_project_scimitar.rbnew file mode 100644index 00000000000..df7cfe17625--- /dev/null+++ b/lib/open_project_scimitar.rb@@ -0,0 +1,49 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module OpenProjectScimitar+ AUTHENTICATION_SCHEMES = [+ Scimitar::AuthenticationScheme.new(+ type: "oauth2",+ name: "OAuth2",+ description: OpenProject::Static::Links.url_for(:sysadmin_docs, :scim_static_access_token_authentication_method)+ ),+ Scimitar::AuthenticationScheme.new(+ type: "oauthbearertoken",+ name: "OAuth Bearer Token",+ description: OpenProject::Static::Links.url_for(:sysadmin_docs, :scim_oauth2_client_credentials_authentication_method)+ ),+ Scimitar::AuthenticationScheme.new(+ type: "oidcjwt",+ name: "OpenID Provider JWT",+ description: OpenProject::Static::Links.url_for(:sysadmin_docs, :scim_jwt_authetication_method)+ )+ ].freeze+enddiff --git a/lib/open_project_scimitar/group.rb b/lib/open_project_scimitar/group.rbnew file mode 100644index 00000000000..9fd560a3704--- /dev/null+++ b/lib/open_project_scimitar/group.rb@@ -0,0 +1,55 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module OpenProjectScimitar+ module Group+ def scim_attributes+ [+ Scimitar::Schema::Attribute.new(name: "displayName",+ type: "string",+ required: true),+ Scimitar::Schema::Attribute.new(name: "members",+ multiValued: true,+ complexType: Scimitar::ComplexTypes::ReferenceMember,+ mutability: "readWrite"),+ Scimitar::Schema::Attribute.new(name: "externalId",+ type: "string",+ uniqueness: "server",+ caseExact: true,+ required: true),+ Scimitar::Schema::Attribute.new(name: "id",+ caseExact: true,+ type: "string",+ uniqueness: "server",+ mutability: "readOnly")+ ]+ end+ end+enddiff --git a/lib/open_project_scimitar/limited_service_provider_configuration.rb b/lib/open_project_scimitar/limited_service_provider_configuration.rbnew file mode 100644index 00000000000..3f9a5919170--- /dev/null+++ b/lib/open_project_scimitar/limited_service_provider_configuration.rb@@ -0,0 +1,56 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module OpenProjectScimitar+ class LimitedServiceProviderConfiguration+ include ActiveModel::Model++ attr_accessor(+ :authenticationSchemes,+ :meta,+ :schemas+ )++ def initialize(attributes = {})+ defaults = {+ meta: Scimitar::Meta.new(+ resourceType: "ServiceProviderConfig",+ created: Time.zone.now,+ lastModified: Time.zone.now,+ version: "1"+ ),+ schemas: ["urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"],+ authenticationSchemes: AUTHENTICATION_SCHEMES+ }++ super(defaults.merge(attributes))+ end+ end+enddiff --git a/lib/open_project_scimitar/name_complex_type.rb b/lib/open_project_scimitar/name_complex_type.rbnew file mode 100644index 00000000000..3f9507fefb8--- /dev/null+++ b/lib/open_project_scimitar/name_complex_type.rb@@ -0,0 +1,35 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module OpenProjectScimitar+ class NameComplexType < Scimitar::ComplexTypes::Base+ set_schema NameSchema+ end+enddiff --git a/lib/open_project_scimitar/name_schema.rb b/lib/open_project_scimitar/name_schema.rbnew file mode 100644index 00000000000..8c2918272db--- /dev/null+++ b/lib/open_project_scimitar/name_schema.rb@@ -0,0 +1,46 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module OpenProjectScimitar+ class NameSchema < Scimitar::Schema::Base+ def self.scim_attributes+ @scim_attributes ||= [+ Scimitar::Schema::Attribute.new(name: "familyName",+ caseExact: false,+ type: "string",+ required: true),+ Scimitar::Schema::Attribute.new(name: "givenName",+ caseExact: false,+ type: "string",+ required: true)+ ]+ end+ end+enddiff --git a/lib/open_project_scimitar/user.rb b/lib/open_project_scimitar/user.rbnew file mode 100644index 00000000000..b98f8e67937--- /dev/null+++ b/lib/open_project_scimitar/user.rb@@ -0,0 +1,65 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module OpenProjectScimitar+ module User+ def scim_attributes+ [+ Scimitar::Schema::Attribute.new(name: "userName",+ type: "string",+ uniqueness: "server",+ required: true),+ Scimitar::Schema::Attribute.new(name: "name",+ complexType: NameComplexType,+ required: true),+ Scimitar::Schema::Attribute.new(name: "active",+ type: "boolean"),+ Scimitar::Schema::Attribute.new(name: "emails",+ multiValued: true,+ complexType: Scimitar::ComplexTypes::Email,+ required: true),+ Scimitar::Schema::Attribute.new(name: "groups",+ multiValued: true,+ complexType: Scimitar::ComplexTypes::ReferenceGroup,+ mutability: "readOnly"),+ Scimitar::Schema::Attribute.new(name: "externalId",+ type: "string",+ uniqueness: "server",+ caseExact: true,+ required: true),+ Scimitar::Schema::Attribute.new(name: "id",+ caseExact: true,+ type: "string",+ uniqueness: "server",+ mutability: "readOnly")+ ]+ end+ end+enddiff --git a/lib/scimitar_schema_extension.rb b/lib/scimitar_schema_extension.rbdeleted file mode 100644index 77a0809ceef..00000000000--- a/lib/scimitar_schema_extension.rb+++ /dev/null@@ -1,151 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--class OpenProjectNameSchema < Scimitar::Schema::Base- def self.scim_attributes- @scim_attributes ||= [- Scimitar::Schema::Attribute.new(name: "familyName",- caseExact: false,- type: "string",- required: true),- Scimitar::Schema::Attribute.new(name: "givenName",- caseExact: false,- type: "string",- required: true)- ]- end-end--class OpenProjectNameComplexType < Scimitar::ComplexTypes::Base- set_schema OpenProjectNameSchema-end--module ScimitarSchemaExtension- AUTHENTICATION_SCHEMES = [- Scimitar::AuthenticationScheme.new(- type: "oauth2",- name: "OAuth2",- description: OpenProject::Static::Links.links[:sysadmin_docs][:scim_static_access_token_authentication_method][:href]- ),- Scimitar::AuthenticationScheme.new(- type: "oauthbearertoken",- name: "OAuth Bearer Token",- description: OpenProject::Static::Links.links[:sysadmin_docs][:scim_oauth2_client_credentials_authentication_method][:href]- ),- Scimitar::AuthenticationScheme.new(- type: "oidcjwt",- name: "OpenID Provider JWT",- description: OpenProject::Static::Links.links[:sysadmin_docs][:scim_jwt_authetication_method][:href]- )- ].freeze-- class LimitedServiceProviderConfiguration- include ActiveModel::Model-- attr_accessor(- :authenticationSchemes,- :meta,- :schemas- )-- def initialize(attributes = {})- defaults = {- meta: Scimitar::Meta.new(- resourceType: "ServiceProviderConfig",- created: Time.zone.now,- lastModified: Time.zone.now,- version: "1"- ),- schemas: ["urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"],- authenticationSchemes: AUTHENTICATION_SCHEMES- }-- super(defaults.merge(attributes))- end- end-- module Group- def scim_attributes- [- Scimitar::Schema::Attribute.new(name: "displayName",- type: "string",- required: true),- Scimitar::Schema::Attribute.new(name: "members",- multiValued: true,- complexType: Scimitar::ComplexTypes::ReferenceMember,- mutability: "readWrite"),- Scimitar::Schema::Attribute.new(name: "externalId",- type: "string",- uniqueness: "server",- caseExact: true,- required: true),- Scimitar::Schema::Attribute.new(name: "id",- caseExact: true,- type: "string",- uniqueness: "server",- mutability: "readOnly")- ]- end- end-- module User- def scim_attributes- [- Scimitar::Schema::Attribute.new(name: "userName",- type: "string",- uniqueness: "server",- required: true),- Scimitar::Schema::Attribute.new(name: "name",- complexType: OpenProjectNameComplexType,- required: true),- Scimitar::Schema::Attribute.new(name: "active",- type: "boolean"),- Scimitar::Schema::Attribute.new(name: "emails",- multiValued: true,- complexType: Scimitar::ComplexTypes::Email,- required: true),- Scimitar::Schema::Attribute.new(name: "groups",- multiValued: true,- complexType: Scimitar::ComplexTypes::ReferenceGroup,- mutability: "readOnly"),- Scimitar::Schema::Attribute.new(name: "externalId",- type: "string",- uniqueness: "server",- caseExact: true,- required: true),- Scimitar::Schema::Attribute.new(name: "id",- caseExact: true,- type: "string",- uniqueness: "server",- mutability: "readOnly")- ]- end- end-enddiff --git a/spec/requests/scim_v2/service_provider_config_spec.rb b/spec/requests/scim_v2/service_provider_config_spec.rbindex bef4fcdcbf1..fdf55759804 100644--- a/spec/requests/scim_v2/service_provider_config_spec.rb+++ b/spec/requests/scim_v2/service_provider_config_spec.rb@@ -46,15 +46,15 @@ RSpec.describe "SCIM API ServiceProviderConfig", with_ee: [:scim_api] doget "/scim_v2/ServiceProviderConfig", {}, headersresponse_body = JSON.parse(last_response.body)- expect(response_body).to include("authenticationSchemes" => [{"description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#a-static-access-token",- "name" => "OAuth2",- "type" => "oauth2"},- {"description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#b-oauth-20-client-credentials",- "name" => "OAuth Bearer Token",- "type" => "oauthbearertoken"},- {"description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#c-jwt-from-identity-provider",- "name" => "OpenID Provider JWT",- "type" => "oidcjwt"}],+ expect(response_body).to include("authenticationSchemes" => [{ "description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#a-static-access-token",+ "name" => "OAuth2",+ "type" => "oauth2" },+ { "description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#b-oauth-20-client-credentials",+ "name" => "OAuth Bearer Token",+ "type" => "oauthbearertoken" },+ { "description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#c-jwt-from-identity-provider",+ "name" => "OpenID Provider JWT",+ "type" => "oidcjwt" }],"bulk" => { "supported" => false },"changePassword" => { "supported" => false },"etag" => { "supported" => false },@@ -65,36 +65,36 @@ RSpec.describe "SCIM API ServiceProviderConfig", with_ee: [:scim_api] do"sort" => { "supported" => false })end- context '' do- let(:token) { OpenStruct.new(plaintext_token: "123123") }+ context "when authorization header contains an invalid token" do+ let(:token) { object_double(Doorkeeper::AccessToken.new, plaintext_token: "123123") }- it "responds with 401 Unauthorized if authorization is incorrect" do+ it "responds with 401 Unauthorized" doget "/scim_v2/ServiceProviderConfig", {}, headers- expect(last_response.status).to eq(401)+ expect(last_response).to have_http_status(401)expect(last_response.body).to eq("invalid_token")endend- context '' do- let(:token) { OpenStruct.new(plaintext_token: "123123") }+ context "when there is no authorization header at all" do+ let(:token) { object_double(Doorkeeper::AccessToken.new, plaintext_token: "123123") }- it "responds with full ServiceProviderConfig information if authorization is absent" do+ it "responds with limited ServiceProviderConfig information" doget "/scim_v2/ServiceProviderConfig", {}, { "CONTENT_TYPE" => "application/scim+json" }- expect(last_response.status).to eq(200)+ expect(last_response).to have_http_status(200)response_body = JSON.parse(last_response.body)expect(response_body.keys).to eq(["meta", "schemas", "authenticationSchemes"])- expect(response_body).to include("authenticationSchemes" => [{"description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#a-static-access-token",- "name" => "OAuth2",- "type" => "oauth2"},- {"description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#b-oauth-20-client-credentials",- "name" => "OAuth Bearer Token",- "type" => "oauthbearertoken"},- {"description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#c-jwt-from-identity-provider",- "name" => "OpenID Provider JWT",- "type" => "oidcjwt"}],- "schemas" => ["urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"],)+ expect(response_body).to include("authenticationSchemes" => [{ "description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#a-static-access-token",+ "name" => "OAuth2",+ "type" => "oauth2" },+ { "description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#b-oauth-20-client-credentials",+ "name" => "OAuth Bearer Token",+ "type" => "oauthbearertoken" },+ { "description" => "https://www.openproject.org/docs/system-admin-guide/authentication/scim/#c-jwt-from-identity-provider",+ "name" => "OpenID Provider JWT",+ "type" => "oidcjwt" }],+ "schemas" => ["urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"])endendend@@ -107,7 +107,7 @@ RSpec.describe "SCIM API ServiceProviderConfig", with_ee: [:scim_api] doexpect(response_body).to eq({ "detail" => "Requires authentication", "schemas" => ["urn:ietf:params:scim:api:messages:2.0:Error"],"status" => "401" }- )+ )expect(last_response).to have_http_status(401)endend