Skip to content

feat(gateway): authenticate requests before forwarding - #79

Merged
FScholPer merged 1 commit into
mainfrom
feat/gateway-auth-401
Nov 24, 2026
Merged

FScholPer merged 1 commit into
mainfrom
feat/gateway-auth-401

Conversation

@alexmohr

@alexmohr alexmohr commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Authenticate requests in the S-CORE gateway before federation, and add the first no-bus reference tester step (S3 step 1).

The gateway serves its own POST /sovd/v1/authorize (ISO 17978-3 §7.23.4) and requires a bearer token on every other endpoint except version-info, which a client reads before it has a token (ISO 17978-3 §5.11; MBDS S-SOVD 2024-07: "Every endpoint besides /version-info, /authorize and /token shall be secured via tokens"). Without a token only GET version-info and POST authorize are answered; anything else, also a path forwarded to the CDA, gets 401.

authorize mirrors the CDA's: the body {"client_id": "...", "client_secret": "..."} is answered with {"access_token": "<jwt>", "token_type": "Bearer", "expires_in": 3600}. A body that is not that JSON object, and empty credentials, get 400. The token has sub (the client_id) and exp claims and is signed with HS256 and the key secret, the development key of the CDA's default security plugin, so the CDA accepts it when the gateway forwards it, also when the CDA is built with its auth feature. That key is a development placeholder: it is public, so anyone can forge a token.

Authentication itself is a placeholder that mirrors the default security plugin of the CDA (auth feature off): any JWT-shaped bearer token is accepted. The gateway does not verify signatures in this mode and does not check the credentials of authorize. It exists until S-CORE has an identity and an issuer. For production, start the gateway with --auth-jwks and --auth-issuer: Core verifies tokens with the external issuer's public keys, and the gateway then serves no authorize.

Reference tester step: through the gateway, the Core client discovers the gateway and CDA version info, lists an offline CDA ECU and follows its rewritten href, and an anonymous request gets 401. The CDA pin is f613cde.

The in-process gateway test checks authorize (token claims and HS256 signature with the CDA's key, bad bodies), the open and protected routes, the placeholder (missing token, wrong scheme, non-JWT token, JWT-shaped token forwarded) and Core's JWKS path (wrong signature and unsigned tokens rejected, signed token forwarded) against a recording upstream.

Checklist

  • I have tested my changes locally
  • I have added or updated documentation
  • I have linked related issues or discussions
  • I have added or updated tests

Related

Part of #66 (S2, first step of S3); follows #70 (merged). Replaces #81.

Notes for Reviewers

  • Linux Bazel tests (--config=score_diag_x86_64_linux): gateway_auth_test, application_registration_test, read_did_bridge_test, //score/opensovd-cda:integration_test and the rest of //examples/... //tests/... //score/... passed (17/17); //score/opensovd-core:all built (8 targets). The mDNS veth test needs root and was not run.
  • macOS Bazel build and tests failed before execution due to unsupported S-CORE C++ platform / Rust host-tool compilation errors.
  • With --auth-jwks, version-info needs a token unless a policy allows it, as in opensovd-core.

Alexander Mohr alexander.m.mohr@mercedes-benz.com, Mercedes-Benz Tech Innovation GmbH
Provider Information

@alexmohr
alexmohr force-pushed the consumable_by_reference_integration branch from 9df754e to 93bbca8 Compare November 23, 2026 09:11
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.8.2) and connecting to it...
INFO: Invocation ID: 8019cdff-b2c5-4e6f-9702-0ccd6c9e87f3
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)

Analyzing: target //:license-check (34 packages loaded, 14 targets configured)

Analyzing: target //:license-check (94 packages loaded, 14 targets configured)

Analyzing: target //:license-check (95 packages loaded, 14 targets configured)

Analyzing: target //:license-check (95 packages loaded, 14 targets configured)

Analyzing: target //:license-check (156 packages loaded, 3240 targets configured)

Analyzing: target //:license-check (156 packages loaded, 3240 targets configured)

Analyzing: target //:license-check (168 packages loaded, 3288 targets configured)

Analyzing: target //:license-check (177 packages loaded, 9668 targets configured)

Analyzing: target //:license-check (177 packages loaded, 9668 targets configured)

INFO: Analyzed target //:license-check (183 packages loaded, 15903 targets configured).
[1 / 1] no actions running
[14 / 17] Generating Dash formatted dependency file ...; 0s disk-cache, processwrapper-sandbox ... (2 actions, 1 running)
INFO: From Generating Dash formatted dependency file ...:
INFO: Successfully converted 2 packages from Cargo.lock to bazel-out/k8-fastbuild/bin/formatted.txt
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 55.621s, Critical Path: 1.86s
INFO: 17 processes: 12 internal, 4 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 17 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

@alexmohr
alexmohr requested a balanced review from Copilot November 23, 2026 09:35
@alexmohr
alexmohr force-pushed the consumable_by_reference_integration branch from 93bbca8 to 1ba1ae2 Compare November 23, 2026 09:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The startup authentication check breaks the existing integration test because its configuration and clients omit authentication, and the JWT/Rego principal guard lacks regression coverage.

2 open issues
What changed in this PR

This PR enables authentication before forwarding in the S-CORE gateway, requiring a deployment-provided bearer token or Core JWT configuration.

Changes:

  • Adds static-token authentication and rejects startup without authentication configuration.
  • Exposes embedded authentication hooks and requires an authenticated principal for JWT/Rego authorization.
  • Adds token validation and forwarding tests, build dependencies, and configuration documentation.
File Description
score/​opensovd-core/​tests/​auth.rs Tests token validation and authentication before forwarding.
score/​opensovd-core/​src/​main.rs Validates authentication configuration and selects the gateway runner.
score/​opensovd-core/​src/​auth.rs Implements static bearer-token authentication and configuration checks.
score/​opensovd-core/​README.md Documents the required authentication configuration.
score/​opensovd-core/​BUILD Adds authentication dependencies and the test target.
patches/​opensovd-core-expose-deps.patch Exposes authentication hooks and prevents anonymous JWT/Rego access.

Review effort: Balanced

Comment thread score/opensovd-core/src/main.rs Resolved
Comment thread patches/opensovd-core-expose-deps.patch Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The static-token HTTP test omits an incorrect-token case, leaving the rejection path unverified and allowing an implementation that accepts every bearer token to pass.

1 open issue
2 resolved since last review

Review effort: Balanced

response = connection.getresponse()
body = response.read()
assert response.status == 401, (response.status, body)
connection.request(

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The integration test helper can wait indefinitely on a stalled gateway connection, blocking startup retries and process-exit checks until Bazel’s overall timeout; the connect/write/read operation needs a bounded timeout.

2 open issues

Review effort: Balanced

Comment thread score/opensovd-cda/tests/integration.rs Resolved
@alexmohr
alexmohr force-pushed the consumable_by_reference_integration branch 5 times, most recently from 8c36b0e to 6b0c9e8 Compare November 24, 2026 10:23
@alexmohr
alexmohr force-pushed the feat/gateway-auth-401 branch 2 times, most recently from 5a75c92 to e8d9712 Compare November 24, 2026 10:50
@alexmohr
alexmohr force-pushed the feat/gateway-auth-401 branch from e8d9712 to 5e315b7 Compare November 24, 2026 14:28
@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-79: https://eclipse-score.github.io/diagnostics/pr-79/

Base automatically changed from consumable_by_reference_integration to main November 24, 2026 14:41
Require bearer authentication before forwarding requests to the CDA.
Keep version discovery public in development mode and expose a local
authorize endpoint that issues development tokens accepted by the CDA.
Use Core’s JWKS validation when an external issuer is configured.

Teach the example client to send bearer tokens and cover anonymous
rejection, token issuance and validation, and no-bus CDA discovery
through the gateway.

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
@alexmohr
alexmohr force-pushed the feat/gateway-auth-401 branch from 5e315b7 to cd3096e Compare November 24, 2026 15:03
@alexmohr
alexmohr marked this pull request as ready for review November 24, 2026 15:11
@FScholPer
FScholPer added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit abcc7d4 Nov 24, 2026
12 checks passed
@FScholPer
FScholPer deleted the feat/gateway-auth-401 branch November 24, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants