Repository navigation
feat(gateway): authenticate requests before forwarding - #79
Conversation
9df754e to
93bbca8
Compare
License Check Results🚀 The license check job ran with the Bazel command: bazel run //:license-checkStatus: Click to expand output |
93bbca8 to
1ba1ae2
Compare
There was a problem hiding this comment.
🟡 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
fd6c536 to
1cde137
Compare
144c5c3 to
a0ffd91
Compare
| response = connection.getresponse() | ||
| body = response.read() | ||
| assert response.status == 401, (response.status, body) | ||
| connection.request( |
d9aa05f to
ef943b0
Compare
There was a problem hiding this comment.
🟡 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
8c36b0e to
6b0c9e8
Compare
5a75c92 to
e8d9712
Compare
e8d9712 to
5e315b7
Compare
|
Documentation preview for this pull request is available at: |
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>
5e315b7 to
cd3096e
Compare


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 exceptversion-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 onlyGET version-infoandPOST authorizeare answered; anything else, also a path forwarded to the CDA, gets 401.authorizemirrors 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 hassub(the client_id) andexpclaims and is signed with HS256 and the keysecret, 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 itsauthfeature. 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 (
authfeature off): any JWT-shaped bearer token is accepted. The gateway does not verify signatures in this mode and does not check the credentials ofauthorize. It exists until S-CORE has an identity and an issuer. For production, start the gateway with--auth-jwksand--auth-issuer: Core verifies tokens with the external issuer's public keys, and the gateway then serves noauthorize.authorizeare supplied to Core's gateway withrun_with_auth_and_shutdownandAuth::with_authorizefrom feat(gateway): run with supplied auth and serve authorize from it eclipse-opensovd/opensovd-core#289 (merged; Core is pinned at ca26b28 offeat/score-integration). With--auth-jwks, Core builds its own authenticator and the hook is not used./authorize(--upstream-authorize-urlis gone), so the gateway's route is the only one.opensovd-corepatch is needed: the Core pin exposes the client, server and shared dependency targets, includingjsonwebtoken(feat: expose S-CORE integration targets eclipse-opensovd/opensovd-core#290). This PR changes no Core code.SOVD_AUTH_TOKENas its client credential; get one fromauthorize.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
Related
Part of #66 (S2, first step of S3); follows #70 (merged). Replaces #81.
Notes for Reviewers
--config=score_diag_x86_64_linux):gateway_auth_test,application_registration_test,read_did_bridge_test,//score/opensovd-cda:integration_testand the rest of//examples/... //tests/... //score/...passed (17/17);//score/opensovd-core:allbuilt (8 targets). The mDNS veth test needs root and was not run.--auth-jwks,version-infoneeds 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