57 Commits

Author SHA1 Message Date
Klaus Zanders 50104b4900 Ensure department check also runs when adding users to a Group via AddUsersService 2026-04-16 17:24:28 +02:00
Jan Sandbrink f9d8bc6614 Introduce SubclassResponsibility error
This error is intended for cases when a method is
intentionally not implemented, because the module/class defining
it expects a subclass (or class including the module) to implement
the method.

This is intended to distinguish it from other cases, such as:
* feature not implemented yet
* edge case of a method call not yet supported

Notably it avoids the misuse of the Ruby-defined NotImplementedError,
which is only intended for much more specific scenarios:

> Raised when a feature is not implemented on the current platform. For example, methods depending on the fsync or fork system calls may raise this exception [...]

Also see https://docs.ruby-lang.org/en/master/NotImplementedError.html
2026-03-27 08:14:56 +01:00
Klaus Zanders 3f83a921b4 Also add children groups as members 2026-03-18 12:09:00 +01:00
Klaus Zanders 9728990fdf Implement membership propagation for memberships 2026-03-16 15:42:31 +01: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
Jan Sandbrink 706fb7c645 Replace user_ids param with (add|remove|replace)_user_ids
Previously it was always necessary to provide a full list of users when calling the service.
Now it's also possible to provide a delta that should be achieved.

This allows to simplify calls to the service, when only the delta is known (e.g. "add this user").
It also makes those calls safer, since the internals of the Groups::UpdateService are already locked
through an advisory lock (via BaseContracted), thus concurrent changes to group memberships are serialized
properly inside the service. However, previous implementations would have read the current members of a group
outside of the service scope, where race conditions could have occured.
2025-07-31 09:32:26 +02:00
Alexander Brandon Coles 5e9f3827f5 Freeze string literals in app/services
rubocop -A --only Style/FrozenStringLiteralComment,Layout/EmptyLineAfterMagicComment,Style/RedundantFreeze app/services
2025-07-18 17:45:24 +01: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 d187b2aab7 Merge remote-tracking branch 'origin/dev' into feature/62107-add-scim-server-api 2025-07-01 10:02:12 +02:00
Jan Sandbrink 40aff02f11 Remove params argument from BaseCallable#perform
This is making the interface of BaseCallable more consistent.
Previously it was unclear, whether the params passed to perform
should be used to reference parameters or whether the attribute accessor
should be used. Different code used different approaches.

To apply this change more consistently, BaseContracted also removed
params from the methods called inside its own perform method, e.g.
before_perform or after_validate.

At a later point we might consider removing this argument from other large
inheritors as well, for example `BaseServices::SetAttributes#set_attributes`.
2025-06-30 11:47:03 +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 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
Ivan Kuchin 4911b8a149 remove years from copyrights (except for COPYRIGHT file) 2024-07-31 15:02:49 +02:00
ulferts 3b2121f733 Revert "Merge remote-tracking branch 'origin/release/13.4' into dev"
This reverts commit 40b2bbeb09, reversing
changes made to b4c6cb17cc.
2024-03-21 11:31:17 +01:00
Ivan Kuchin 7787e457a3 Revert "Merge branch 'dev' into release/13.4"
This reverts commit a901541269, reversing
changes made to e573ca00b7.
2024-03-20 20:19:08 +01:00
Ivan Kuchin 9e4934cd0a change quotes using rubocop --only Style/StringLiterals,Style/QuotedSymbols -a 2024-03-20 18:05:22 +01:00
Christophe Bliard 8fa8584538 Run rubocop --autocorrect on all files
Only the safe cops have run. rubocop version is 1.59.0.
2024-01-05 15:27:09 +01:00
Christophe Bliard c795874f7f Update copyright year for 2024
command used: `rg -l 'Copyright \(C\) 2012-202\d the OpenProject' | xargs -n 100 sed -i -r 's/Copyright \(C\) 2012-202. the OpenProject/Copyright (C) 2012-2024 the OpenProject/'`
2024-01-02 16:23:54 +01:00
Klaus Zanders 0c7fd939c8 Fixes Performance/MapCompact offenses 2023-09-06 11:06:36 +02:00
Klaus Zanders 47222a8dc4 Fix query for inserting roles 2023-09-05 13:04:14 +02:00
Klaus Zanders 0148e5a1f7 Implement role denormalization of group memberships for users 2023-09-05 13:04:12 +02:00
Klaus Zanders 7586152dfb Remove specific columns from conflict resolution 2023-09-05 13:04:12 +02:00
Klaus Zanders 5bea68ad88 Revert "Update code that builds inherited roles to include work_package_id"
This reverts commit 6dbf144749.
2023-08-08 10:09:13 +02:00
Klaus Zanders 6dbf144749 Update code that builds inherited roles to include work_package_id 2023-08-08 10:02:14 +02:00
Christophe Bliard 9e865b4f7b lint: Run rubocop safe autocorrect
Command is `rubocop --safe --autocorrect app lib lib_static modules spec`
2023-03-09 10:25:57 +01:00
Christophe Bliard a06e519ed7 Set send_notifications only when not nil
When calling a service with `send_notifications: false`, the
`Journal::NotificationConfiguration.active?` will be set to `false` and
subsequent calls to set it to `true` will have no effect and log a
warning.

For this reason, it's better to use `nil` as default value for
`send_notifications` so that
`Journal::NotificationConfiguration.active?` is changed only when the
value is explicitly `true` or `false`, and ignored when the value is
`nil`.
2023-02-27 17:47:34 +01:00
Oliver Günther 863ffe3341 Merge remote-tracking branch 'origin/release/12.4' into dev 2023-02-23 16:18:51 +01:00
Oliver Günther 447151fc98 Restore suppressing of notifications in groups service 2023-02-22 14:24:01 +01:00
Oliver Günther cbc05b0848 Merge remote-tracking branch 'origin/release/12.4' into dev 2023-01-04 20:50:41 +01:00
ulferts cbc7b9f124 optimize creating memberships for groups
Before, all the projects the group might have been in before the new
membership got created were considered by the SQL which potentially
results in a lot of records to be processed (the results were correct).
Now, only the project the new membership is created for is considered in
the SQL as that is the only project in which the group's users could
rightfully become members now.
2023-01-04 10:50:11 +01:00
Christophe Bliard 21a696ef9b Update copyright information for 2023 2022-12-30 15:51:26 +01:00
Christophe Bliard 48986c80be Make String#squish remove sql comments
Add `using CoreExtensions::SquishSql` to use it.
2022-09-19 10:17:43 +02:00
Christophe Bliard b50855a955 Use ServiceResult factory methods where possible
All was automatic through the use of `rubocop --autocorrect --only
OpenProject/UseServiceResultFactoryMethods app lib lib_static modules
spec`.
2022-06-16 10:01:57 +02:00
Christophe Bliard 48a4f1b6ad lint with rubocop --autocorrect (safe cops only) 2022-06-02 10:40:10 +02:00
ulferts 9b8e5d6216 keep roles inherited from different group on role adding 2022-04-26 20:44:00 +02:00
Christophe Bliard a33524ef6d remove ruby magic comment for utf-8
ruby interprets source encoding as utf-8 since 2.0.0, making magic comment redundant and useless
2022-03-10 19:36:58 +01:00
Christophe Bliard bc8d423ec2 update copyright information for 2022 2022-03-01 17:05:59 +01:00
Christophe Bliard 582c811091 fix bug: no more anonymous user when notifying of group membership removals
before, the email sent on group membership removal/ deletion was from Anonymous user. Now it is from the real user having performed the action in the administration
2022-01-31 18:25:22 +01:00
Christophe Bliard 7d862d4cc8 Update global role for users belonging to a group having global role 2022-01-31 09:32:32 +01:00
Christophe Bliard 482407392b add global role to users when added to a group having global role 2022-01-31 09:32:30 +01:00
ulferts 816057e65e allow suppressing notifications on member create/update 2021-12-14 15:28:09 +01:00
Markus Kahl d86e2787c7 Merge branch 'release/11.4' into dev 2021-10-20 13:44:48 +01:00
Markus Kahl 379a0969bb handle invalid group_users entries, prevent new ones 2021-10-08 14:47:48 +02:00
Oliver Günther ccfa29c728 Move license and copyright docs to root, fix names and references 2021-09-02 21:50:46 +02:00
Markus Kahl dc89c9a46d Revert "try to fix NPE when adding user to group at times"
This reverts commit 3f4b303c79.
2021-08-20 15:02:55 +01:00
Markus Kahl 3f4b303c79 try to fix NPE when adding user to group at times 2021-08-20 14:44:16 +01:00
Oliver Günther 843779c483 [38017] Don't remove group users if no replacement provided
https://community.openproject.org/wp/38017
2021-07-14 21:48:22 +02:00
ulferts d1f419385f Feature/member custom notifications (#9173)
* include custom message in membership forms

* keep pristine params to be able to pass it to the state

* fix indentation on projects api docs

* pass grape instance around in default endpoints

The grape instance has readily available access to all the objects (params, current_user) so less individual parameters need to be passed. This also avoids having to store the grape endpoint in a potentials not thread safe variable

* send custom message out on membership creation

* send custom message on membership update

* send custom message even if setting disabled

* restore params interface

* add custom message description to schema

* describe notificationMessage in the api documentation

* extract meta payload functionality into mixin

* ensure password in spec meets requirements

* Update docs/api/apiv3/endpoints/members.apib

Co-authored-by: Oliver Günther <mail@oliverguenther.de>

* Update docs/api/apiv3/endpoints/members.apib

Co-authored-by: Oliver Günther <mail@oliverguenther.de>

* Update docs/api/apiv3/endpoints/members.apib

Co-authored-by: Oliver Günther <mail@oliverguenther.de>

* Update docs/api/apiv3/endpoints/members.apib

Co-authored-by: Oliver Günther <mail@oliverguenther.de>

* Update docs/api/apiv3/endpoints/members.apib

Co-authored-by: Oliver Günther <mail@oliverguenther.de>

Co-authored-by: Oliver Günther <mail@oliverguenther.de>
2021-04-26 16:26:04 +02:00
ulferts 9fa5599392 Feature/member notifications (#8958)
* spec with correctly scoped links

* move db check into own file - fix deprecation

* basic spec for member creation service

* use constants for all notifications

* send an OP notification after member has been created

* send an OP notification after member has been updated

* mails on group member added

Depending on whether the membership existed before or not, an updated or
a created notification is send. This is done asynchronously.

* move all mail sender background jobs into namespace

* wip

* wip

* correct handling group member notifications

* add setting enable/disable mail sending on member alterations

* use services in members controller

* move Notifiable to OpenProject

* remove member after save hooks

* cleanup/testing/linting

* render member mails in receiver locale

* remove add_member! method

* use mailer layout for all mailers

* Update app/services/groups/cleanup_inherited_roles_service.rb

Co-authored-by: Oliver Günther <mail@oliverguenther.de>

* use around callback to avoid prepending

* handle nil params

Co-authored-by: Oliver Günther <mail@oliverguenther.de>
2021-04-20 13:45:42 +02:00
ulferts b8ca382d34 Group API (#9034)
* include group members into resource

* GET /api/v3/groups endpoint

* POST /api/v3/groups

* PATCH /api/v3/groups/:id

* DELETE /api/v3/groups/:id
2021-02-23 09:59:49 +01:00