27 Commits

Author SHA1 Message Date
Madhu Reddy 1f7146b2fa [#73431] Add tests for duplicate SCIM v2 user results
Adds request specs for the SCIM v2 users index endpoint to make sure
each user is returned only once, even with multiple group memberships
or auth provider links.

Covers the duplicate-record regression caused by joined relations.
2026-03-26 13:50:32 +05:30
Jan Sandbrink 649119b83c Include resource_metadata in WWW-Authenticate header
This is giving clients another chance to discover the metadata URL.
2025-12-10 08:47:35 +01:00
Jan Sandbrink 99ddb6752f Remove feature toggle for SCIM API
This has been part of OpenProject for a few releases
already and there is no need to disable it anymore.
2025-12-09 08:37:36 +01:00
Jan Sandbrink 5c41f592b2 Add scope-hint to WWW-Authenticate header
This one is defined as optional by RFC 6750, which defines
the usage of bearer tokens. It allows a client to know, which
scopes are required to access a given resource when using Bearer tokens.
2025-12-03 15:56:21 +01:00
Pavel Balashou 5add4fbbe8 [#67055] Do not use unspecified ServiceProviderConfig.AuthenticationSchemes.type
https://community.openproject.org/work_packages/67055
2025-09-23 10:24:14 +02:00
Pavel Balashou 6e2487ac9f Merge pull request #20055 from opf/feature/66706-responds-with-403-and-proper-message-when-enterprise-plan-is-not-enough
[#66706] Responds with 403 and proper message when enterprise plan is not enough.
2025-08-27 17:01:12 +02:00
Pavel Balashou b5e5b00c63 [#66706] Responds with 403 and proper message when enterprise plan is not enough.
https://community.openproject.org/work_packages/66706
2025-08-27 16:32:00 +02:00
Pavel Balashou 1323927095 [#65068] Add deleted status to user.
https://community.openproject.org/work_packages/65068
2025-08-27 09:53:37 +02:00
Pavel Balashou 47049c156e [#66434] Update scimitar.
- Use custom_authenticator provied by scimitar to do authentication.
- Polish specs a bit.
- Rework OpenProject scimitar modifications structure.

Co-Authored-by: Jan Sandbrink <j.sandbrink@openproject.com>
2025-08-15 15:04:22 +02:00
Pavel Balashou 35486e70f6 [#66434] /ServiceProviderConfig endpoint responds with limited output without authorization.
https://community.openproject.org/work_packages/66434
2025-08-13 16:03:33 +02:00
Pavel Balashou 89ada61e15 [#65855] Fix group membership management for Keycloak SCIM plugin.
https://community.openproject.org/work_packages/65855

There is a bug in scimitar which breaks create and replace actions when $ref sub attribute is present.
Before it is fixed we just remove this attribute from params for GroupsController#create and GroupsController#replace
actions.
2025-07-15 11:34:44 +02:00
Pavel Balashou 061592af7d [#65747] Make SCIM /Schemas reflect real behavior.
- Refactor SCIM error handling logic.
- Make SCIM /Schemas reflect real behavior.
  Add `id` attribute.
  Change caseExact to be false everywhere excerpt `id` and `externalId`.
  See https://github.com/pond/scimitar/blob/09b284778340ee067df9e5140d0230386afb9992/README.md#omissions
  for details. And I checked actual source code. There is no place where caseExact values specified in schema
  are respected. Only `id`, `externalId` and `meta.*` are matched case-sensitively.
- Extend filtering specs with upcased/downcased search terms.
- Change formatting of long spec examples.
2025-07-11 19:15:34 +02:00
Pavel Balashou dbd95a2ace [#65747] Make /scim_v2/Schemas endpoint return required by OP schemas.
https://community.openproject.org/work_packages/65747

- Make /scim_v2/Schemas endpoint return OP required schemas.
  Set required field to be required(givenName, familyName, email etc.).
  Set caseSensetive to be true where it is case sensetive.
  Remove fields that are not used by OpenProject.
  Note: making fields as requried make scimitar check their presence and
  responds with 400 which is useful.
- Refactor SCIM API controllers by extracting error handling in a general(🫡) method
- Add extra specs
- Restyle SCIM API specs a bit with hope that it makes them more readable...
2025-07-10 18:13:21 +02:00
Pavel Balashou ed795610be Revert " [#65747] Make /scim_v2/Schemas endpoint return required by OP schemas."
This reverts commit b249fd36b4.
2025-07-10 18:12:29 +02:00
Pavel Balashou b249fd36b4 [#65747] Make /scim_v2/Schemas endpoint return required by OP schemas.
https://community.openproject.org/work_packages/65747

- Make /scim_v2/Schemas endpoint return OP required schemas.
  Set required field to be required(givenName, familyName, email etc.).
  Set caseSensetive to be true where it is case sensetive.
  Remove fields that are not used by OpenProject.
  Note: making fields as requried make scimitar check their presence and
  responds with 400 which is useful.
- Refactor SCIM API controllers by extracting error handling in a general(🫡) method
- Add extra specs
- Restyle SCIM API specs a bit with hope that it makes them more readable...
2025-07-10 18:00:19 +02:00
Jan Sandbrink e02e72f52d Add enterprise checks for SCIM API
Including a banner for the UI (currently using a placeholder image)
and a check for SCIM API calls.

While it's theoretically possible to setup a client without an enterprise
token (new/edit/create/update are not guarded), there is no click path to
create a client and eventually the API requests would be blocked.
2025-07-04 11:32:33 +02:00
Pavel Balashou cad4a3dba1 [#62107] Fix UserAuthProviderLink.users association. 2025-07-03 10:50:50 +02:00
Pavel Balashou 601b054e04 [#62107] React on PR comments volume 2.
- Fix some Rubocop complains.
- Does not set user.firstname and user.lastname to stupid values.
  To avoid confusion.
- Add inverse_of option to user_auth_provider_links -- provider association.
- Extract ScimitarSchemaExtension module to a dedicated file.
- Fix users/delete_service_spec.rb
2025-07-03 02:59:23 +02:00
Pavel Balashou 662f6a535b [#62107] Update SCIM Server API yet another time.
- Disable Rails/HttpPositionalArguments completely.
  It is often not relevant and breaks specs when rubocop -a is used.
- Support excludedAttributes for all enpoints in SCIM Server API
- Fix excludedAttributes to handle nested attributes correctly. e.g. name.givenName
- Respond with 403 whne User can't be deleted due to lack of permissions.
- Refactor scim related code by removing duplication where possible.
- Remove BasicAuth from supported auth schemes.
- Add specific specs to test SCIM authentication.
- Extend specs.
2025-07-01 22:43:53 +02:00
Pavel Balashou 4e6f018f3e [#62107] Update SCIM Server API.
- Use ServiceAccount associated with ScimClient for making user changes
- Remove scoping by scim_client.auth_provider_id
  So, SCIM Client has access to any not_builtin User.
- Associate user with AuthProvider configured in ScimModel
  instead of choosing the first one.
2025-06-26 18:45:52 +02:00
Pavel Balashou 3b083cec26 [#62107] Update SCIM Server API.
- Use authenticated ServiceAccount in requests
- Scope User and Group requests by ScimClient related auth_provider_id
- Include ServiceAccount search to doorkeeper_oauth strategy
- Fix SCIM Server API specs.
2025-06-26 16:41:45 +02:00
Pavel Balashou bfe8f32e16 [#62107] Update SCIM server API.
- Implement excludedAttributes for GET requests.
- Handled uniqueness violations for group creatation.
- Make sure PATCH works with adding/replacing/removing group members.
- Pick one user email from a list: primary => work => first alphabetical.
- Mark group as inactive before DeleteJob is scheduled.
2025-06-24 11:05:58 +02:00
Pavel Balashou 004a71bb0c [#62107] Fix specs.
- Use correct association name.
2025-06-17 16:24:26 +02:00
Pavel Balashou 5fe52f3a64 [#62107] Update a few SCIM related things.
- Enable SCIM Patch.
- Use user_auth_provider_links instead of users.identity_url.
- Extend SCIM ActiveRecord base scopes to join and preload appropriate associations.
- Set a stub for user.firstname and user.lastname if they are not provided by SCIM client.
- Handle user unique constraint vialation according to SCIM spec.
- Move user_auth_provider_links association to principal as group needs it as well.
- Set user.mail dynamically from the list of emails provided by SCIM client.
- Change BaseServices::Create contract to accept model instance as a constructor parameter.
  It gives an option to build associations before model creation.
- extend SCIM server API schema to include externalId.
- Adjust specs.
2025-06-17 11:03:28 +02:00
Pavel Balashou 326b781c0b [#62107] Fix SCIM PUT. Disable SCIM PATCH.
ServiceProviderConfig enpoint will communiczte that PATCH is not supported.
PATCH is optional according to the specificaiton.
Main reason for disabling it:
it requires special treatment of adding/removing group members,
because in OpenProject it should be done through service(Groups::UpdateSerivce which
uses Groups::AddUsersService underneath), not model association.
2025-06-05 13:16:45 +02:00
Pavel Balashou 22efc29371 [#62107] React to the PR comments. 2025-06-05 13:16:45 +02:00
Pavel Balashou af05f29bbf [#62107] Add SCIM server API
https://community.openproject.org/work_packages/62107
2025-06-05 13:16:44 +02:00