416 Commits

Author SHA1 Message Date
Oliver Günther 4cc9faef4f Consistently use OpenProject::SqlSanitization instead of forwarding to sanitize_sql_array 2026-05-27 10:08:16 +02:00
Oliver Günther d314c487d5 Use registry for associated journal objects, not hard coded map 2026-05-07 10:34:06 +02:00
Eric Schubert 2d38741b37 [#73855] fixed unit tests 2026-04-29 12:03:23 +02:00
Eric Schubert 44f61bf2ee [#73855] move URL escaping of location param to representer 2026-04-28 17:25:56 +02:00
Marcello Rocha 73911fcab8 Fix Sharepoint StorageFile building when Site and List have the same name (#22239)
* Removed unused objects... it seems some tests still relied on them.
* Adds validation keys that where missing
* Update the AMPF validator chaging the create folder validation
* Error handling on FileInfo validation and tests for the Site/List case
* Fix sharepoint factory to include the trailing slash

Co-authored-by: Jan Sandbrink <j.sandbrink@openproject.com>
2026-03-10 14:54:07 +01:00
Jan Sandbrink 0934ca1056 Allow changing forbidden storage characters via API 2026-02-26 16:12:54 +01:00
Jan Sandbrink cc75f5ded4 Remove unused feature flag
Checking for the flag was removed already, but its definition
was not yet removed.
2025-12-09 08:35:31 +01:00
ulferts 7653fbf66b workspace references in representers and auxilliary endpoints 2025-11-25 16:47:59 +01:00
Yauheni Suhakou 3c7055fbe3 [#66623] Harmonise input data of download link query and open file link query (#20732)
Refactor DownloadLink for Storages. 

Change DownloadLink input to accept file_id instead of file_link object. Update the contract and all usages in the API, providers, and specifications. Add optional origin_name for Nextcloud compatibility. Improves consistency between download and open link APIs.
2025-11-13 16:50:37 +01:00
Kabiru Mwenja 0df57ad060 Merge branch 'dev' into merge-release/16.4-20250917064829 2025-09-17 09:52:44 +03:00
Marcello Rocha fb0e2d4756 [#67233] Update CreateFolderService to handle sharepoint (#20309)
* Update CreateFolderService to handle sharepoint
* unwraps Failure(Error)
2025-09-16 11:30:51 +02:00
Jan Sandbrink 389835e6bf Fix translation of dry validation contracts
Sometimes dry-validation would overwrite our custom english
messages with its default messages, recognizable by lacking a
dot at the end.

By using our own top_namespace AND ensuring that dry doesn't load
its own translations, this could be fixed. It means that we will have
to define all messages ourselves, we can't rely on default translations.
2025-09-09 15:58:30 +02:00
Marcello Rocha e9daa1ea51 FeatureDecision for Sharepoint and Renaming of namespaces (#19953)
* Adds FeatureDecision. Initial steps on SharePoint -> Sharepoint rename
* Update I18n keys to use sharepoint over share_point
* Adds handling of the drives on the file picker
* Upload Strategy handling plus FileLink Contract ammendment
2025-08-20 14:53:49 +02:00
Jan Sandbrink ed8310840c Add missing property to storages API
For single-sign-on there is the need to configure scopes
obtained during token exchange as well.
2025-08-11 13:17:50 +02:00
Marcello Rocha 70df9c728e Adds missing param 2025-07-25 11:56:04 +02:00
Marcello Rocha d8c3d3450d [64180] Creating the Sharepoint Storage Model (#19541)
* Drafting a draft implementation draft
* Adds missing token exchange scope
* Remove all mention to list constants
* Changes to SharePoint rather than Sharepoint
* Addresses feedback by @kharonus
* Remove PROVIDER_TYPES
2025-07-17 16:07:41 +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 b78678c5ec Load STI models explicitly.
Due to STI nature it is required. Otherwise undesired behavior is possible
in dev and test environments(where usually lazy loading is enabled).
The udesired behavior can be like:
  Fetching not loaded yet STI model through its parent model
  (e.g. `User.find(service_account_id)` raises `ActiveRecord::NotFound`, because
  `ServiceAccount` has not been referenced yet.

`SubclassRegistry` has been removed, because:
1. `.register_subclasses` and `.registered_subclasses` produce unexpected results.
    ```ruby
      # e.g.: Principal -> User -> ServiceAccount
      Principal.register_subclass(User)

      # Then
      Principal.registered_subclasses == [User] # true
      User.registered_subclasses == [User] # true
      ServiceAccount.registered_subclasses == [User] # true
      # Having User as a subclass of User and ServiceAccount seems to be weird.
    ```

2. There seems to be no big win in have the additional list of subclasses that have to be manually filled.
3. Used in commit apprach seems to be simpler.
   It is just calling STI classes explicitly in to_prepare block of configuration.
2025-06-20 17:00:08 +02:00
Jan Sandbrink 8bbb3b188b Deprecate outdated API link
Having a separate "ensure connection" link does not add
any value, because even the original "open" link does redirect
unconnected users properly. On the other hand, immediately returning
an ensure_connection URL is only possible if the storage was configured
for mutual OAuth 2 authentication, not for authentication through an
SSO provider.
2025-05-12 15:35:59 +02:00
Jan Sandbrink d6d9c54741 Frozen string literals for storages and openid_connect
Enforce frozen string literals across the storages module and
the openid_connect module.
2025-05-05 09:19:08 +02:00
Jan Sandbrink 6a4cd884e1 Rework "open storage" action
The previous implementation was a deeply nested decision tree for
different error cases or other unexpected states.

Most of this was necessary, because setting up correct permissions is partially
happening asynchronously. Some of the redirects would eventually have rendered a modal
that would periodically check whether user permissions appeared in the background.

All of this was replaced by an approach where we immediately (synchronously) ensure
that the setup is correct.
2025-04-29 11:07:17 +02:00
Jan Sandbrink caafcde3b0 Fix SSO storage creation via API
There were several bad assumptions in the previous
implementation. First, the represented is not a storage,
but effectively a Hashie::Mash, so just a fancy hash.
Thus methods such a provider_type_nextcloud? don't exist,
but sadly no error is raised, because `?` methods will just
return false if a key with the same name is missing.

Also on a more general level, it doesn't make sense skip parsing
certain fields depending on the type, because we can't make sure
that the type is being parsed first. Thus we might skip parsing
fields and afterwards realize that we should have parsed them
in the first place.

If we wanted to prevent assigning attributes that we don't want to
assign, it would be the responsibility of SetAttributesService
and contracts to ensure that.
2025-03-24 09:23:41 +01:00
Jan Sandbrink 75e14af5c2 Merge pull request #18336 from opf/storage-api
Make storage audience and authentication method available in API
2025-03-18 07:48:40 +01:00
Jan Sandbrink d778915c83 Make storage audience and authentication method available in API
This brings the API on par with the UI, where this is already configurable.
2025-03-17 15:19:43 +01:00
Jan Sandbrink 27b7b95906 Print proper title for provider type in API
Even OneDrive storages did indicate a title of "Nextcloud", which
is pretty surely not intended.
2025-03-17 15:19:43 +01:00
Jan Sandbrink 0c90b8b9e0 Allow access to new file links by creator
For example on the work package create UI, it
is already possible to link files, even though the
WP does not yet exist. In this case it's a usability
issue if the UI elements do not yet work as they should.

As long as there is no associated container, it should be no
issue to assume that the creator has all the necessary permissions
to view a file link. Downloading the associated file is still
limited by permissions on the storage, so this should not
be abusable to retain long-term access to a file.
2025-03-12 08:05:43 +01:00
Jan Sandbrink 6785cf87e7 Failed HTTP requests do not raise errors from TOKEN_OBTAINED_EVENT
We will now propagate HTTP errors upwards as failed service results,
top-most they are only logged, but will not raise an error anymore.

We can do this, because a missing remote identity will be shown to
the user as an error anyways. On the other hand raising an error
from the OpenProject::Notifications breaks the code performing
the original token fetching and prevents display of the nice error
message in the UI.
2025-03-05 16:51:37 +01:00
Jan Sandbrink c7ead14870 Differentiate error handling for storages
Introducing an explicit difference between users that were never linked
and those that have a link (i.e. a remote identity) but receive an authentication
error anyways. There is also differentiation between SSO users and non-SSO users.
When authenticating to the storage via SSO, it wouldn't make sense to show a login
button to users.
2025-03-04 08:35:29 +01:00
Pavel Balashou aae3b48ba5 [#61178] Add test related to RemoteIdentity upd. 2025-02-28 17:52:24 +01:00
Pavel Balashou 7445f846db [#61178] Address PR comments.
- Use SpecificBearerToken as a name for new auth strategy
- Add scope to filter storages by audience
- Do not emit REMOTE_IDENTITY_CREATED event if there are no changes to the model
- Use TOKEN_OBTAINED_EVENT for event exposed by openid_connect module
- Fix fetching of RemoteIdentity data in all cases to be correct, I hope :)
2025-02-28 14:11:06 +01:00
Pavel Balashou 2277dec69f [#61178] Update RemoteIdentity after token obtained. 2025-02-27 14:02:56 +01:00
Jan Sandbrink f71f0dd930 Ensure to select auth strategy via storage registry
There were a few places left that hardcoded the userbound strategy
to OAuthUserToken, which used to be the only strategy for userbound
authentcation. However, by now there is also SSO-based authentication
which requires the use of a different strategy.
2025-02-27 08:24:56 +01:00
Eric Schubert 52a670c487 [#60151] enable nextcloud storages with sso strategy
- https://community.openproject.org/work_packages/60151
- add decision logic, which strategy to use for nextcloud storages
- add sso user token logic with token exchange
2025-02-07 13:17:03 +01:00
Ivan Kuchin 0b8308e419 unify procs and lambdas in module menus 2025-01-16 15:11:37 +01:00
Jan Sandbrink 07a2b146ae Add short-hand syntaxes to add reference replacements
There is now add_replacements which accepts a hash, allowing to
add multiple replacements in one call. This should make mass-adding
replacements look less bulky.

Also including helpers to ActsAsOpEngine to make adding replacements
from a module nicer.
2024-12-19 11:09:19 +01:00
Jan Sandbrink 4536859663 Refactor ReplaceReferencesService
Instead of expecting modules to selectively overwrite
methods of this class, we offer an explicit extension point
where replacements can be registered explicitly.

Thus patching the implementation is not necessary anymore, instead
it can be configured from initializers.
2024-12-19 08:24:41 +01:00
OpenProject Actions CI e54011a631 Merge branch 'release/15.1' into dev 2024-12-19 03:41:29 +00:00
Oliver Günther 6dc3ede584 Replace references 2024-12-18 10:49:59 +01:00
Andreas Pfohl b7e97523dc Merge pull request #17403 from opf/code-maintenance/59468-api-remove-embedding-of-file-links-collection-from-work-package-resource
[59468] Removed embedded file links colelction from work package resource
2024-12-11 13:39:30 +01:00
Andreas Pfohl 33276fcdfa [59468] Removed embedded file links colelction from work package resource 2024-12-11 09:34:19 +01:00
Bruno Pagno e711b17bed implement API for creating folt statusders 2024-12-10 18:07:21 +01:00
Eric Schubert 6e0947974d [#59391] applied PR comments 2024-11-20 14:55:53 +01:00
Eric Schubert e86d5bd251 [#59391] updated API specs for new pagination in file links
- avoid sql injection
- file link collection is returned ordered by id asc
2024-11-20 13:24:40 +01:00
Eric Schubert 4f47e3fdc4 [#59391] rework file links to paginated collection
- https://community.openproject.org/wp/59391
- files tab counter now only calls for file links of wp with page size 0
- file links endpoint returns paginated collections
- frontend requests file links with page size -1 (INFINITE)
- file sync is still executed for ALL file links of a work package, not
  only the requested page
  - this is practically no change for the product, as we do not fetch
    single pages
  - but fetching only the total numbers with page size 0 now does not
    trigger a sync
2024-11-20 13:24:38 +01:00
Marcello Rocha 59c92f41ae Update tests to rely on the registry 2024-09-18 15:28:19 +02:00
Marcello Rocha 3214cd78cb Update copyright where missing 2024-09-18 13:03:10 +02:00
Marcello Rocha 0aac18fce0 Replace short_provider_type with implicit to_s 2024-09-18 13:03:10 +02:00
Marcello Rocha fbe1215365 Adds the copyright blocks 2024-09-17 11:45:00 +02:00
Marcello Rocha ac08605ef6 Introduces the UploadLinkService 2024-09-17 11:44:59 +02:00
Kabiru Mwenja 141b3b40d5 Merge branch 'release/14.5' into dev 2024-09-06 12:55:10 +03:00