Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add authorization to all endpoints #786

Closed
6 tasks done
ds-lcapellino opened this issue Mar 26, 2024 · 10 comments · Fixed by #1129 or #1135
Closed
6 tasks done

Add authorization to all endpoints #786

ds-lcapellino opened this issue Mar 26, 2024 · 10 comments · Fixed by #1129 or #1135
Assignees
Labels
backend Backend related issues bug Something isn't working

Comments

@ds-lcapellino
Copy link
Contributor

ds-lcapellino commented Mar 26, 2024

As a Trace-X admin, (ROLE_ADMIN)
I want to have all my endpoints secured via a Trace-X role,
so that my application is secured against unwanted access.

Blocker

We do not have a technical user on INT environments. Therefore, we need a concept how to authenticate (e.g. API key?)

Hints / Details

for example, is not secured with any role. This could be resolved with adding:
@PreAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_SUPERVISOR', 'ROLE_USER')")

All endpoints of

are unprotected.

Acceptance Criteria

  • all endpoints need at least the ROLE_USER role for allowed usage (SubmodelController)
  • Insomnia collection is updated and published to team members
  • documentation is updated
  • frontend provides additional view for triggering private api endpoints (sync, /api/registry/reload $assetId)
    • usage of C-X style guide
    • User feedback executing action - Reasonable message mapping http status code.

Out of Scope

  • ...
@jzbmw jzbmw added the backend Backend related issues label Apr 23, 2024
@mkanal mkanal added the bug Something isn't working label Jun 21, 2024
@ds-mwesener ds-mwesener self-assigned this Jun 25, 2024
@ds-mwesener
Copy link
Contributor

ds-mwesener commented Jun 28, 2024

Two issues for discussion

Issue 1:

Called from our Dataplane

FIRST APPROACH: These paths could be secured via network settings -> only access allowed within the cluster:

  • /qualitynotifications/receive
  • /qualityalerts/receive
  • /qualitynotifications/update
  • /qualityalerts/update
  • /callback/endpoint-data-reference
  • /internal/endpoint-data-reference

SECOND APPROACH: Alternatively, we could use the possibility of the EDC: EDC HTTP Data Plane.

This has never been tested and involves several processes, e.g., IRS data asset registration, Trace-X data ingest, GitHub Action Pipeline for setup of environments. Due to the high impact and complexity, the first approach (securing via network settings) is the preferred and more straightforward solution.

Issue 2:

Used by IRS to Send Job Completed Info

  • /irs/job/callback

Currently, in IRS, there is no mechanism for authentication. It would be easy to work with a key within the jobRegistration. This key could be transferred to the /irs/job/callback address and validated to ensure that the request is acceptable.

Derived ticket for IRS for evaluation: eclipse-tractusx/item-relationship-service#740

Info from EDC team regarding usage of api key: https://matrix.to/#/!mYxOilDPMLCQhMoIVc:matrix.eclipse.org/$cCww_Sp9NEocHYou8rzvPFcxaBtFLEc-BHLr7ULH-DE?via=matrix.eclipse.org&via=matrix.org&via=dev-null.rocks

The api key solution is also involved in several process and therefore still the more effort solution.

@mkanal
Copy link
Contributor

mkanal commented Jun 28, 2024

Issue 1:

OPTION: Using API Keys instead of OAuth 2.
FIRST APPROACH: In my understanding, this option does not fit the goal of this story to secure the api endpoints in general.
SECOND APPROACH: Here I need some more details to understand what is extended here.

@mkanal
Copy link
Contributor

mkanal commented Jul 1, 2024

Target solution is to secure the endpoints via OAuth2 or API Key. We create a ticket for the target solution.
Now FIRST APPROACH will be implemented.

@ds-mwesener
Copy link
Contributor

As discussed the following was defined:

Issue 1: We will use approach one and secure the apis to be only accessible within the kubernetes cluster.
As a long term solution we created a story: #1132

Issue 2: IRS will evaluate an approach of how they can accept a authentication parameter. So that trace-x can use it to secure the api..

@ds-mwesener
Copy link
Contributor

No insomnia update required.
Internal accessible APIs are returning a 404 from outside of the cluster:

image

@ds-mwesener
Copy link
Contributor

ds-mwesener commented Jul 2, 2024

Added some documentation here:

Added known known here:

@ds-crehm
Copy link
Contributor

ds-crehm commented Jul 3, 2024

Tested on E2E: Cannot access endpoints through Insomnia. I get a 404 for all of them.

However, internal requests are failing as well. Sending notifications does not work currently and in the logs an identical error is mentioned: 2024-07-03T08:26:16.066Z WARN 1 --- [nio-8080-exec-7] o.e.t.t.c.config.TrustedEndpointsFilter : /api/internal/qualitynotifications/receive
2024-07-03T08:26:16.066Z WARN 1 --- [nio-8080-exec-7] o.e.t.t.c.config.TrustedEndpointsFilter : denying request for trusted endpoint on untrusted port

@ds-mwesener
Copy link
Contributor

Hi @ds-crehm as discussed the public api should return 404 on the internal apis. I have fixed the behaviour that the notification callback apis used the wrong url. Now it should work please validate.

@ds-crehm
Copy link
Contributor

ds-crehm commented Jul 4, 2024

Tested on dev/test & E2E: Notifications can be sent again now. Endpoints are properly secured.
Ready for review.

@ds-crehm ds-crehm assigned mkanal and unassigned ds-mwesener and ds-crehm Jul 4, 2024
@mkanal
Copy link
Contributor

mkanal commented Jul 4, 2024

LGFM PO acceptance in behalf of @jzbmw

@mkanal mkanal closed this as completed Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend related issues bug Something isn't working
Projects
Status: done
5 participants