Commit Graph

154 Commits

Author SHA1 Message Date
Oliver Günther 96d703d863 Merge remote-tracking branch 'origin/release/17.4' into dev 2026-05-19 11:09:41 +02:00
Oliver Günther ecfe44b22f Add missing msgpack require 2026-05-19 11:08:53 +02:00
Oliver Günther ac46afc084 Merge remote-tracking branch 'origin/release/17.4' into dev 2026-05-19 10:27:31 +02:00
Oliver Günther 6d0b39b466 Merge pull request #23251 from opf/fix/use-message-pack-cache-serializer
Use MessagePack serializer that treats old marshal cache as miss
2026-05-19 10:26:48 +02:00
Eric Schubert f3f8625434 [chore] removed docs and code insertions for custom header
- X-Requested-With header no longer needed to prevent CSRF for session
  based auth
- removed occurences and mentions from code and docs
2026-05-12 08:13:14 +02:00
Jan Sandbrink 0383ae171c Consider Sec-Fetch-Site header for session auth
This warden strategy is primarily used to allow APIv3 requests
from the browser, which only authenticates using its session cookie.

Since this is susceptible to cross-site-request-forgery, prevention of
CSRF must take place. This was so far only ensured through the usage of
the X-Requested-With header. When a client sent along this header, the
server could know that a CORS-preflight request must have been made and
thus the browser most certainly has validated that the request is valid
according to CORS rules.

However, the header itself is a non-standard header and while some JavaScript
frameworks add it to requests, not all of them do. For us this was practically
visible on the API docs hosted under `/api/docs`.

The solution is to expect the browser to send the Sec-Fetch-Site header with a value
of same-origin. This header can't be set through JavaScript, but only by the browser
and the value "same-origin" ensures that scheme, host and port are the same for requester
and requested endpoint, thus eliminating CSRF concerns. This feature is widely supported by
all major browsers, the last of which was Safari which added support 3 years ago.

We might want to consider dropping the check for X-Requested-With entirely, since it should be
superfluous. For now it was left in place for greater compatibility.
2026-05-12 08:13:14 +02:00
Klaus Zanders c502885230 Add allow_enabling attribute to FeatureDecisions 2026-05-05 11:57:29 +02:00
Klaus Zanders de15253cc2 Fix DynamicFindBy issues in our Codebase 2026-04-27 09:20:11 +02:00
Markus Kahl a89cfaa2ec allow space separated list for IPs, document list delimiters 2026-03-05 12:15:36 +00:00
Markus Kahl 42d97005e2 add OpenProject::SsrfProtection, use it when sending test email to prevent attack 2026-03-05 12:15:35 +00:00
Jan Sandbrink eb73e27e23 Merge pull request #21968 from opf/rename-rest-api-enabled
Rename rest_api_enabled to api_tokens_enabled
2026-02-13 09:52:58 +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
Jan Sandbrink 508c8bbad7 Always respond in Bearer method for WWW-Authenticate header
The intention of this change is to always respond in the metadata-rich
version of the header that indicates things like the required scope and
the URL of the resource_metadata endpoint, which was previously hidden
and only visible if clients used a non-standard HTTP request header.

semantically it's probably the preferable version of the header by now
anyways, because:

* all APIs accept some kind of Bearer token, not all of them accept Basic auth
* Even API tokens can now be passed as Bearer tokens

Practically the Basic auth header also caused unintended browser pop-ups when the frontend
code didn't include the correct request header to avoid the Basic auth offer, this now can't
happen anymore, since the Basic auth version of the header is only returned, if the client actively
tried to authenticate through Basic auth.
2026-02-10 09:02:07 +01:00
Jan Sandbrink 4d305df714 Allow to use API Tokens as Bearer tokens
We generate those tokens with a prefix, so that we
can decide by looking at a token, whether it's an API Token
or a different kind of token, so that we can decide which
code path to choose for validating the token.

The usage of access tokens as Bearer token has the usability advantage,
that you can paste them as plaintext into tools that expect you
to specify the token as a header.

Also the Basic auth approach for our old tokens usually rather caused
issues, such as browsers prompting for credentials in surprising situations.
If we were to deprecate basic authentication one day, this change today could've
been the first step towards that.
2026-02-05 08:07:04 +01:00
Jan Sandbrink 78f8607de6 First implementation of MCP API server in OpenProject
So far the MCP server only offers a single tool, but authentication
and integration is already built in a way that's intended to last.

Ideally extensions to this happen by adding additional tools or resources,
but will not require further architectural changes, though realistically we'll
probably identify more potential for reuse, once we added a few more tools.

The exact representation of results is still slightly to-be-discussed. Right
now we are using vanilla APIv3 representation, which might be enough, but possibly
we want to represent linked resources differently, so that they can be recognized
to be fetchable via MCP resources more easily.
2026-01-05 08:28:45 +01:00
Jan Sandbrink a200c8c8dd Extract trace_exception method from monitoring helpers
The OpenTelemetry and Appsignal helpers were already able to
be hooked into logging, but didn't offer public methods to plainly
trace the occurence of an exception. For both helpers this was possible
to be extracted directly from the existing code.
2026-01-05 08:26:40 +01:00
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 167304552f Properly escape values in WWW-Authenticate
We even had a spec testing behaviour of a string that needed
escaping, but due to the fact that we constructed the relatively large
header content in the spec, we never noticed that escaping was indeed
missing in that case.
2025-12-03 15:56:21 +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
Christophe Bliard a6aac70270 Fix detection of worker process type 2025-11-17 16:36:47 +01:00
Alexander Brandon Coles 9ff68b84c6 Fix wording (code): change "expiry" to "expiration" 2025-11-11 20:29:04 +00:00
Alexander Brandon Coles 5fbc204fd2 Fix missing copyright notices in lib_static 2025-10-06 13:12:03 +02:00
Alexander Brandon Coles 50be32c606 Freeze string literals in lib_static
rubocop -A --only Style/FrozenStringLiteralComment,Layout/EmptyLineAfterMagicComment,Style/RedundantFreeze lib_static
2025-10-06 13:12:02 +02:00
Christophe Bliard a69859f0ec [67642] Avoid error when attachment is not uploaded yet
https://community.openproject.org/wp/67642

Attachments::ExtractFulltextJob is run twice:
- one time on creation
- one time when the direct upload is completed

When it runs on creation, and the attachments are stored on S3, the
attachment is in 'prepared' status and is not complete yet.

Due to a bug in carrierwave which is fixed since June 2023 (see
https://github.com/carrierwaveuploader/carrierwave/issues/2524), the
`#local_file` method raises the error "NoMethodError: undefined method
'body' for nil:NilClass". There is a separate issue for upgrading this
dependency one day: https://community.openproject.org/wp/67626.

The fix is to call `#local_file` only if the attachment is readable.

Additionnally:
- error handling has been updated to raise the error instead of
  swallowing it silently, so well have proper reporting in AppSignal
  next time.
- when a custom S3 endpoint is used (for local testing with minio for
  instance), this custom endpoint is added to the CSP.

Co-authored-by: Jan Sandbrink <j.sandbrink@openproject.com>
2025-09-24 10:21:22 +02:00
Christophe Bliard 18b6233d55 Adjust some OpenTelemetry configuration
- Use constants for semantic names. As a bonus it gives documentation
  about the metric.
- Use a random UUID for the service name. It has to be unique for a
  given service name and namespace.
- Use process type as service name.
- Add service version.

Do not set anything regarding the environment (edge / stage / prod) or
shard name as these will be available as k8s labels anyway.
2025-09-22 15:02:07 +02:00
Oliver Günther 59446719c9 Transform values to_s 2025-09-17 15:48:25 +02:00
Oliver Günther bf93b827b3 Tag opentelemetry request 2025-09-17 15:32:27 +02:00
Alexander Brandon Coles 2b144e8542 Fix wording: Change "Favored" to "Favorited"
Favorite is the correct term in the context of expressing a preference
for a particular project / other OpenProject domain object.

Updates `ActsAsFavorable` to `ActsAsFavoritable`, as well as filenames,
identifiers and strings to:

    favored => favorited
    favorable => favoritable
    favoring => favoriting
2025-09-10 19:08:15 +01:00
Oliver Günther da6fe7c012 Make term_on_timeout configurable 2025-08-11 11:16:48 +02:00
as-op 12a52c6582 fix link to docs [skip ci] 2025-07-07 15:29:12 +02:00
as-op 729cfceb95 fix link to blog [skip ci] 2025-07-07 13:05:49 +02:00
Pavel Balashou 19d7642334 [#62107] Reacto on PR comments.
Co-Authored-by: Jan Sandbrink <j.sandbrink@openproject.com>
2025-07-02 15:30:24 +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 b0b20c90d7 Merge remote-tracking branch 'origin/dev' into feature/62107-add-scim-server-api 2025-06-24 11:12:33 +02:00
OpenProject Actions CI e7dc967164 Merge branch 'release/16.1' into dev 2025-06-19 03:47:52 +00:00
Jan Sandbrink 1e97636b91 Check active state of user during SQL query
This should be a tad faster for the case where the user is not activated, because
the result is already filtered when fetching from the database.

Co-authored-by: Pavel Balashou <ba1ashpash@gmail.com>
2025-06-18 16:11:44 +02:00
Jan Sandbrink cfcb7f3874 Properly check whether user is locked
The current implementation opens a small window of
opportunity to authenticate through a previously issued
access token even after a user account was locked.

If access tokens had a longer lifetime, this could become
a large window of opportunity.
2025-06-18 09:04:16 +02:00
Pavel Balashou 004a71bb0c [#62107] Fix specs.
- Use correct association name.
2025-06-17 16:24:26 +02:00
Pavel Balashou 70e30e74bf Merge remote-tracking branch 'origin/dev' into feature/62107-add-scim-server-api 2025-06-17 11:05:03 +02:00
Oliver Günther 7cf82a737b Primerize trial creation 2025-06-13 14:47:43 +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 f37ba8ce5d Merge branch 'dev' into feature/63912-support-multiple-authentication-provider-user-links 2025-06-11 10:18:34 +02:00
ulferts 309c27cbc6 limit forced activation of feature flags to prod and dev 2025-06-05 17:01: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 586fc6ba02 Merge branch 'dev' into feature/63912-support-multiple-authentication-provider-user-links 2025-06-03 10:13:30 +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
Jan Sandbrink 6fc2fcf434 Merge pull request #19017 from opf/global-warden
Make warden available across entire application
2025-05-27 17:04:02 +02:00
Jan Sandbrink 1fafb59c18 Refactor DoorkeeperOAuth strategy
This was initiated by Rubocop complaining
about the method complexity.

Rewriting it with no changes.
Adding additional test cases to specify expected behaviour,
also making edge cases visible that are otherwise covered by
separate feature specs in a different location.
2025-05-26 16:43:09 +02:00
Jan Sandbrink a5986538e6 Only accept access tokens of enabled OAuth applications
We introduced the ability to disable doorkeeper applications in
the past, but apparently we didn't check that an application whose
token we validate is also enabled.

Now we make sure that only tokens of enabled applications are accepted.
2025-05-26 15:31:53 +02:00