-
Notifications
You must be signed in to change notification settings - Fork 90
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
chore(backend): replace GrantReference with OutgoingPaymentGrant #800
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me. Thank you!
🤔 Would we still want to be able to link resources with the corresponding grants used to create them, for auditing or some other purpose? |
@wilsonianb It feels like the "RTP" is more of a general concept in this case right? i.e. RTP != RS? In general, having more information about the grant would be a good thing IMO, could do further checks other than the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments, but wouldn't mind going the other way and expanding the info stored in the og grantreference table
@@ -60,7 +60,7 @@ async function createQuote( | |||
receiver: body.receiver, | |||
sendAmount: body.sendAmount && parseAmount(body.sendAmount), | |||
receiveAmount: body.receiveAmount && parseAmount(body.receiveAmount), | |||
grantId: ctx.grant?.grant | |||
clientId: ctx.grant?.clientId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will this have to change with #688?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'd be able to keep our current logic of defining ctx.clientId
for everything except read-all/list-all requests
rafiki/packages/backend/src/open_payments/auth/middleware.ts
Lines 80 to 84 in 3a3f9e8
// Unless the relevant grant action is ReadAll/ListAll add the | |
// clientId to ctx for Read/List filtering | |
if (access.actions.includes(action)) { | |
ctx.clientId = grant.clientId | |
} |
export class OutgoingPaymentGrant extends DbErrors(Model) { | ||
public static get modelPaths(): string[] { | ||
return [__dirname] | ||
} | ||
public static readonly tableName = 'outgoingPaymentGrants' | ||
public id!: string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in its own file? I was trying to find the model when I pulled down the branch originally, but wasn't able to right away
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to go all in on confining this to outgoing payments.
Are you thinking a separate model file in this directory, or its directory with its own service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense - I was thinking of having one model per file in general, but if its confined as such and won't grow beyond its current scope, then it's good here
//lock grant | ||
await deps.grantReferenceService.lock(grant.grant, deps.knex) | ||
// Lock grant | ||
// TODO: update to use objection once it supports forNoKeyUpdate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a separate issue for this? Or too far out/uncertain just yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a PR that I could include in the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok for now. Also, I'm guessing reviews haven't been fast on this because of: Vincit/objection.js#2335. Would be good to keep an eye on this thread
I'm not sure if our RS is more like the RTP or FSP. Either way, I think we should associate created resources with corresponding grants for auditing purposes. I think just storing the grant id on the resource is currently sufficient with the RS bound to the AS. (The single account provider can look up grant details in the AS db tables. Although maybe we'd need to expand admin api to do so.) |
Yeah, because of how the RS & AS are tied together, all the info can be found in the AS anyway if an audit is needed. I like that this simplifies things a bit in general + we don't need extra DB calls for incoming payments & quotes. I could see this changes down the line but LGTM for now |
Changes proposed in this pull request
clientId
directly on payment pointer subresourcesContext
Checklist
fixes #number