Skip to content

Commit

Permalink
Merge pull request eclipse-tractusx#581 from catenax-ng/feature/TRI-1…
Browse files Browse the repository at this point in the history
…604-concept-EDR-cache-and-reuse

feat(docs):[TRI-1604] Add concept for EDR caching and reuse
  • Loading branch information
ds-jhartmann authored Oct 12, 2023
2 parents 9198633 + a2f149c commit 395ce29
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions docs/concept/EDR-Token-Cache-and-reuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# \[Concept\] \[TRI-1604\] EDC EDR Token negotiation and usage

## Glossary

| Abbreviation | Name |
|--------------|------------------------------|
| EDR | EndpointDataReference |
| EDR-Storage | EndpointDataReferenceStorage |

## Existing flow - single use token

The existing flow of token negotiation and usage only allows to use a negotiated contract and the resulting EDR (
Endpoint Data Reference) Token to be used once.
After the token is consumed, it is removed from the EDR-Storage (EndpointDataReferenceStorage).

```mermaid
sequenceDiagram
autonumber
participant EdcSubmodelClient
participant ContractNegotiationService
participant EndpointDataReferenceStorage
participant EdcCallbackController
participant EdcDataPlaneClient
EdcSubmodelClient ->> ContractNegotiationService: Negotiate new EDR Token
ContractNegotiationService -->> EdcCallbackController: EDC flow
EdcCallbackController ->> EndpointDataReferenceStorage: Store EDR token by contract agreement id after EDC callback
loop While EDR Token is not present
EdcSubmodelClient ->> EndpointDataReferenceStorage: Poll for EDR Token
end
EndpointDataReferenceStorage ->> EdcSubmodelClient: Return EDR Token
EdcSubmodelClient ->> EdcDataPlaneClient: Get data(EDR Token, Dataplane URL)
EdcDataPlaneClient ->> EdcSubmodelClient: Return data
```

## New flow - reuse token

To increase performance for assets with the same EDC contract, IRS should be able to reuse an existing EDR token.

To make this possible, two things have to be adjusted.

1. IRS has to check first, if an EDR Token for the requested EDC Asset ID is available in EDR-Storage
2. EDR Tokens have to be stored in the EDR-Storage with the EDC Asset ID as key instead of contract agreement id

```mermaid
sequenceDiagram
autonumber
participant EdcSubmodelClient
participant ContractNegotiationService
participant EndpointDataReferenceStorage
participant EdcCallbackController
participant EdcDataPlaneClient
EdcSubmodelClient ->> EndpointDataReferenceStorage: Get EDR Token for EDC asset id
EndpointDataReferenceStorage ->> EdcSubmodelClient: Return Optional<EDR Token>
alt Token is present and not expired
EdcSubmodelClient ->> EdcSubmodelClient: Optional.get
else
alt Token is expired
EdcSubmodelClient ->> ContractNegotiationService: Renew EDR Token based on existing Token
else Token is not present
EdcSubmodelClient ->> ContractNegotiationService: Negotiate new EDR Token
end
ContractNegotiationService -->> EdcCallbackController: EDC flow
EdcCallbackController ->> EndpointDataReferenceStorage: Store EDR token by EDC asset id after EDC callback
loop While EDR Token is not present
EdcSubmodelClient ->> EndpointDataReferenceStorage: Poll for EDR Token
end
EndpointDataReferenceStorage ->> EdcSubmodelClient: Return EDR Token
end
EdcSubmodelClient ->> EdcDataPlaneClient: Get data(EDR Token, Dataplane URL)
EdcDataPlaneClient ->> EdcSubmodelClient: Return data
```

### Case: Token already present in EDR-Storage

```mermaid
flowchart LR
A[EDR Token] --> B[extract authCode]
B --> C[decode JWT]
C --> D[get expiry date 'exp']
D --> E{isAvailable}
E -->|Yes| F{isValid}
E -->|No| H[Request new Token]
F -->|Yes| G{isExpired}
F -->|No| H
G -->|Yes| H
G -->|No| I[Reuse Token]
```

### Case: Token is expired

```mermaid
sequenceDiagram
autonumber
participant EdcSubmodelClient
participant ContractNegotiationService
participant EndpointDataReferenceStorage
participant EdcCallbackController
EdcSubmodelClient ->> EdcSubmodelClient: extract contract agreement ID 'cid' from Token authCode
EdcSubmodelClient ->> ContractNegotiationService: start transfer process(EDC asset ID, cid, connector URL, connector ID)
ContractNegotiationService -->> EdcCallbackController: EDC flow
EdcCallbackController ->> EndpointDataReferenceStorage: Store EDR token by EDC asset id after EDC callback
loop While EDR Token is not present
EdcSubmodelClient ->> EndpointDataReferenceStorage: Poll for EDR Token
end
EndpointDataReferenceStorage ->> EdcSubmodelClient: Return EDR Token
```

0 comments on commit 395ce29

Please sign in to comment.