467 Commits

Author SHA1 Message Date
as-op 6b53b36b1d fix regression with curly apostrophe 2026-05-26 12:43:35 +02:00
as-op 86d65f1a96 split the VALID_NAME_REGEX for better reuse
fixes code review issue https://github.com/opf/openproject/pull/23306#discussion_r3302834272
2026-05-26 12:29:48 +02:00
Klaus Zanders 6ad3509043 Proper handling of ResourceAllocation when the user is deleted 2026-05-13 09:07:28 +02:00
Oliver Günther c660802146 Merge remote-tracking branch 'origin/release/17.3' into release/17.4 2026-05-06 09:19:25 +02:00
Oliver Günther 6877e29351 Validate current user password confirmation when changing passwords through API
https://community.openproject.org/work_packages/74335
2026-04-23 14:19:50 +02:00
Oliver Günther 5c2801646f short-circuit more permission checks if you're an active admin
https://community.openproject.org/projects/openproject/work_packages/73538/activity
2026-03-31 10:24:04 +02:00
Klaus Zanders 4854b1ecab Fix rubocop issues 2026-03-06 13:39:39 +01:00
Klaus Zanders 6460304e8f Correctly implement quick methods to get working days for user 2026-03-06 13:28:45 +01:00
Klaus Zanders 727cb945e8 Refactor UserNonWorkingDay into a model that covers date ranges 2026-03-06 13:28:35 +01:00
Klaus Zanders 5518a468ea Add methos to retrieve non working days quickly 2026-03-06 13:27:59 +01:00
Klaus Zanders 8cb25833de Add working hours and non working days for users 2026-03-06 13:27:42 +01:00
Ivan Kuchin 73803c59cd add admin_only_allowed setting to acts_as_customizable 2026-02-25 20:07:13 +01:00
Jan Sandbrink d61bb47b2b Rename rest_api_enabled to api_tokens_enabled
The name of this setting was pretty outdated by now.
It might have disabled the entire API in the past, but that time
is long gone. By now the APIv3 can't be disabled at all and OpenProject
would fall apart if it was disabled.

The only thing that this setting changes, is whether users can create
an access token in their account settings and whether tokens created
this way are accepted by OpenProject. So naming and description have
been adapted accordingly.
2026-02-13 09:24:53 +01:00
Klaus Zanders 640088148e Add proper inverse relations for reucrring meeting and user 2025-12-08 09:47:56 +01:00
ulferts b519d2cf43 prevent saving of the user within the execute_as_admin block 2025-11-19 14:57:41 +01:00
ulferts e0b383d613 allow elevating user to admin within block 2025-11-19 11:53:00 +01:00
Jan Sandbrink e400fd7e4c Allow changing password if it exists
Previously we'd be hiding the "change password" dialog on the
basis of an external authentication method existing. However, that's
not enough, because (at least with user remapping enabled) it's possible
that a user that logged in via password once, gained the ability to login
through SSO afterwards. Such a user then can use both mean to authenticate,
thus they also need to be able to change a potentially compromised password.

Much more work is needed here: Users need to be aware that their password still
works, they need to be able to delete a password if they only want to use SSO and
maybe there's also a use case for deleting an SSO association and going back to
password-based logins. However, all of these things require more UI changes and
some proper product development first.

This change is a first step to improve the situation.
2025-11-10 14:00:02 +01:00
Oliver Günther 0733913cf6 Adapt CF validation after core changes 2025-10-23 14:06:36 +02:00
Oliver Günther 3836fc8be1 Allow validations to be skipped when inviting users 2025-10-21 10:01:29 +02:00
Oliver Günther ff4f683561 Move try_to_autologin into CurrentUser concern 2025-09-24 13:46:09 +02:00
Klaus Zanders 3b4bc98f6a Link the ical meetings token to the user 2025-08-18 13:42:34 +02:00
Marcello Rocha 55ff4d6903 Rework of Storages Registry based approach (#17881)
* Re-creates the Registry and Errors under the Adapters namespace.
* Bring Authentication and Strategies to Adapters
* Make Strategies work with Result and clean up a bit of the code
* Setup SetPermissions Command and tests
* Moves create folder, need to add the input value
* Adds the create folder input
* RenameFile migrated
* Files Query and some Result Objects
* Gets the sync service working with the new commands/query
* UploadLinkQuery ported
* FileInfoQuery ported
* FilePathToIdMap moved
* Cleanup unused files and warnings
* Moves DeleteFolder. Updates tests of OneDriveSyncService
* Add some tests for the the inputs
* Start moving the bare minimum for the NextcloudSync
* Moves nextcloud FilePathToIdMap
* Create and Delete Folder nextcloud commands
* Port Nextcloud FileInfo and RenameFile
* Implements the changes necessary for create folder on the file picker
* Moves the CreateFolderService to the Adapters
* Move Nextcloud SetPermissions
* AuthCheck moved. Missing teests. Slowly moving the API to Adapters
* Adds note to figure out the open queries
* Move the user and group manipulation to adapters
* Moves Nextcloud FilesQuery
* Makes NextcloudSync to run on top of the new Adapter namespace
* Disable Peripherals::Registry
* Update CopyTemplateFolderService
* Makes services green again. Moves the new Nextcloud contract to Adapters
* Moves the new nextcloud contracts and fixes some the now broken tests
* Reintroduces the Internal namespace in OneDrive. Updates the contracts for Strategy to optionally take a storage (OIDC issues)
* Moves User and DownloadLink Queries and supporting code.
* Start to move the API over the new commands/queries
* Migrates the StorgeFilesAPI to the adapters
* FileLinksAPI cleared
* Updates the Storages API specs and implementations
* OpenStorage API done
* Update capabilities query
* Move connection validators and fix some broken tests
* Delete old code, update hidden dependencies.
* Adds missing handling for sso tokens
2025-07-10 09:01:55 +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 dd7a6f0727 Merge branch 'feature/62107-add-scim-server-api' into scim-authentication 2025-06-24 11:14:15 +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
Jan Sandbrink 99ad5d99e9 Require authentication for SCIM requests
Handling authentication through our regular warden strategies.

Permissions-wise the only thing we can check for is whether the authenticated
user is an admin. Though this will require us to grant admin privileges to
all SCIM clients, which might be more than we want to do.
2025-06-17 12:57:45 +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 7031218224 Merge branch 'dev' into feature/62107-add-scim-server-api 2025-06-13 10:25:45 +02:00
Pavel Balashou 4d35299d67 [#63912] Try to fix migrations CI run. 2025-06-06 15:01:17 +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 af05f29bbf [#62107] Add SCIM server API
https://community.openproject.org/work_packages/62107
2025-06-05 13:16:44 +02:00
Pavel Balashou 83794a7466 [#63912] React on PR comments.
Important changes:
1. Use ignored_columns to try to avoid downtime.
2. Add unique constraint for auth_provider_id+external_id.

Co-authored-by: Jan Sandbrink <453584+username@users.noreply.github.com>
2025-06-05 13:03:13 +02:00
Pavel Balashou 2db9ef305c [#63912] Support multiple authentication provider user links
https://community.openproject.org/work_packages/63912
2025-06-03 10:13:00 +02:00
Alexander Brandon Coles 08b77022c5 Disable InverseOf cop for User#oauth_grants
There is no inverse association defined and we do not "own"
`Doorkeeper::AccessGrant`.
2025-03-03 13:59:41 -03:00
Alexander Brandon Coles 218c4c9e96 Add missing dependent option on User has_many assocs. 2025-03-03 13:59:41 -03:00
Klaus Zanders dee5feb67d Merge branch 'dev' into merge-release/15.3-20250225143729 2025-02-25 15:41:27 +01:00
Kabiru Mwenja f2c12315e6 bug/61756 Cannot delete users who have work package reminders (#18067)
Add missing active record assoc dependent destroy strategy. Destroy reminder notifications join table first to avoid foreign key violation

https://community.openproject.org/work_packages/61756
2025-02-25 10:12:49 +03:00
ulferts de6ea69115 Merge remote-tracking branch 'origin/release/15.3' into dev 2025-02-24 14:54:48 +01:00
Kabiru Mwenja cf643f93b1 bug/61708 Cannot delete users who used emoji reactions (#18053)
Add missing active record user association with dependent destroy

https://community.openproject.org/work_packages/61708
2025-02-24 12:19:22 +03:00
Alexander Brandon Coles 7a5124522c Fix typo in user_format: s/coma/comma/ 2025-02-14 07:27:08 -03:00
Jan Sandbrink 3708fa4513 Expose User#authentication_provider as AR class
Previously we only got the slug name of the provider
as a string, which doesn't allow to further use the provider.

Converting it back into its AR representation allows to call
further methods on it, e.g. checking support for certain capabilities.
2025-01-20 14:09:00 +01:00
Oliver Günther 32d4da11a0 Fix and add test for self-registration 2024-10-21 13:03:52 +02:00
Jens Ulferts 048e728e11 Merge pull request #16567 from opf/bug/56771-meeting-timestamp-in-edit-form-not-the-same-as-in-details
Bug/56771 meeting timestamp in edit form not the same as in details
2024-09-26 14:51:04 +02:00
ulferts cd615f5108 move shared function user code into module 2024-09-24 14:26:21 +02:00
Pavel Balashou 32843020ad [#57835] Use advisory lock to synchronize token refresh process.
https://community.openproject.org/work_packages/57835

Let's assume we have two OpenProject threads sent request to Nextcloud and received Unauthorized. Then each does the following:
   A. Send refresh token request on Nextcloud side.
   B. Send original request but with new token received in A.
   C. If B is successful then update token in OpenProject DB.

There are problems with above:
1. Before this commit the three operations above are not synchronized which leads to incostistent state when
token has been updated on Nextcloud side, but it is not saved in OpenProject DB.
2. Step B and C logic is wrong. Original request can be unsuccessful even with updated token. That's no reason to skip
updating the token in OpenProject DB.

What has changed in this commit?
The logic has been changed to the following:
   1. Try to acquire a lock. Acquired?
     A. Yes.
       1. Send refresh token request on Nextcloud side.
       2. Update token in OpenProject DB.
       3. Relese the lock.
       4. Send original request but with new token received in 1.
     B. No. Then respond with error.

There are two main points introduced:
1. Advisory lock around refresh token request to Nextcloud and update token data in OpenProject DB.
2. Removal of wrong condition(when updating the token data in OpenProject DB depends on successful repetition of
original request to Nextcloud but with newly received token)
2024-09-18 14:13:12 +02:00
ulferts 4c61ce1bfc increase time_zone robustness 2024-09-06 10:14:40 +02:00
ulferts 1d7fd3c2ec nil memoized tz variable on reload 2024-09-02 18:11:41 +02:00