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

Pin 5687: Verify tenant certified attributes for agreement creation #1224

Merged
merged 65 commits into from
Dec 5, 2024

Conversation

AsterITA
Copy link
Contributor

@AsterITA AsterITA commented Nov 22, 2024

Closes PIN-5607

This route will check the tenant attributes against the selected descriptor when creating an agreement for itself or for a delegator

  • Reimplement with suggestions from PR
  • Reimplement tests

Creating agreement without a delegation (Creating for itself)
immagine

Creating agreement with a delegation by the delegate
immagine

Creating agreement when not the delegate nor for himself
immagine

Creating agreement for itself when there's a valid delegation
immagine

@AsterITA AsterITA marked this pull request as ready for review November 22, 2024 16:11
Copy link
Collaborator

@ecamellini ecamellini left a comment

Choose a reason for hiding this comment

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

Do we need to implement this logic in the agreement process?
I think we have everything we need already in the BFF, the call is named /agreements/verify but it doesn't seem to be related to agreements since an agreement does not yet exist (unless I am missing something).

I think we can do everything in the BFF, doing something similar to what @MalpenZibo did in #1218, but simpler:

  1. We GET the delegation
  2. We GET the delegator from the delegation
  3. We use the hasCertifiedAttributes utility (already implemented in BFF) and return true if it's true for at least one of these tenants

Let me know what you think. I would also consider renaming the call since it is not related to agreements but just to the verification of attributes given a descriptor and a delegation

@AsterITA AsterITA requested a review from sandrotaje December 4, 2024 10:44
@AsterITA AsterITA requested a review from ecamellini December 4, 2024 10:54
Copy link
Collaborator

@ecamellini ecamellini left a comment

Choose a reason for hiding this comment

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

Just one minor suggestion 👌

.with(
"eServiceNotFound",
"descriptorNotFound",
() => HTTP_STATUS_BAD_REQUEST
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't be a not found?

Copy link
Contributor Author

@AsterITA AsterITA Dec 4, 2024

Choose a reason for hiding this comment

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

shouldn't be a not found?

In these cases we usually decide which is the main "subject" of the route, on which we return 404 if not found (in this case the tenant), meanwhile the other objects if not found we return a 400 since it's an incorrect input.

We can rethink this behaviour if we want, but for now it's of the same pattern in various mappers

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok to leave it like this also for me, when this route is called we shall have eservice and descriptor defined and found, tenant is the main subject (the potential consumer, it can be any tenant) - the case where they are not should not be possible, so I think it's ok to return a bad request and not 404

Base automatically changed from PIN-5607_DelegatedConsumerAgreementCreation to feature/incaricato December 5, 2024 11:01
@AsterITA AsterITA merged commit 3b514ed into feature/incaricato Dec 5, 2024
50 checks passed
@AsterITA AsterITA deleted the PIN-5687_agreementsVerify branch December 5, 2024 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants