mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-03 19:25:19 +02:00
check authz before consuming project action quota
This commit is contained in:
parent
cd6ff9a46f
commit
7592df8068
4 changed files with 12 additions and 12 deletions
|
|
@ -52,9 +52,6 @@ export class CreateCachedTurnUseCase implements ICreateCachedTurnUseCase {
|
|||
// extract projectid from conversation
|
||||
const { projectId } = conversation;
|
||||
|
||||
// assert and consume quota
|
||||
await this.usageQuotaPolicy.assertAndConsume(projectId);
|
||||
|
||||
// authz check
|
||||
await this.projectActionAuthorizationPolicy.authorize({
|
||||
caller: data.caller,
|
||||
|
|
@ -63,6 +60,9 @@ export class CreateCachedTurnUseCase implements ICreateCachedTurnUseCase {
|
|||
projectId,
|
||||
});
|
||||
|
||||
// assert and consume quota
|
||||
await this.usageQuotaPolicy.assertAndConsume(projectId);
|
||||
|
||||
// create cache entry
|
||||
const key = nanoid();
|
||||
const payload: z.infer<typeof CachedTurnRequest> = {
|
||||
|
|
|
|||
|
|
@ -44,9 +44,6 @@ export class CreateConversationUseCase implements ICreateConversationUseCase {
|
|||
let isLiveWorkflow = Boolean(data.isLiveWorkflow);
|
||||
let workflow = data.workflow;
|
||||
|
||||
// assert and consume quota
|
||||
await this.usageQuotaPolicy.assertAndConsume(projectId);
|
||||
|
||||
// authz check
|
||||
await this.projectActionAuthorizationPolicy.authorize({
|
||||
caller,
|
||||
|
|
@ -55,6 +52,9 @@ export class CreateConversationUseCase implements ICreateConversationUseCase {
|
|||
projectId,
|
||||
});
|
||||
|
||||
// assert and consume quota
|
||||
await this.usageQuotaPolicy.assertAndConsume(projectId);
|
||||
|
||||
// if workflow is not provided, fetch workflow
|
||||
if (!workflow) {
|
||||
const project = await projectsCollection.findOne({
|
||||
|
|
|
|||
|
|
@ -59,9 +59,6 @@ export class FetchCachedTurnUseCase implements IFetchCachedTurnUseCase {
|
|||
// extract projectid from conversation
|
||||
const { projectId } = conversation;
|
||||
|
||||
// assert and consume quota
|
||||
await this.usageQuotaPolicy.assertAndConsume(projectId);
|
||||
|
||||
// authz check
|
||||
await this.projectActionAuthorizationPolicy.authorize({
|
||||
caller: data.caller,
|
||||
|
|
@ -70,6 +67,9 @@ export class FetchCachedTurnUseCase implements IFetchCachedTurnUseCase {
|
|||
projectId,
|
||||
});
|
||||
|
||||
// assert and consume quota
|
||||
await this.usageQuotaPolicy.assertAndConsume(projectId);
|
||||
|
||||
// delete from cache
|
||||
await this.cacheService.delete(`turn-${data.key}`);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,9 +51,6 @@ export class RunConversationTurnUseCase implements IRunConversationTurnUseCase {
|
|||
// extract projectid from conversation
|
||||
const { id: conversationId, projectId } = conversation;
|
||||
|
||||
// assert and consume quota
|
||||
await this.usageQuotaPolicy.assertAndConsume(projectId);
|
||||
|
||||
// authz check
|
||||
await this.projectActionAuthorizationPolicy.authorize({
|
||||
caller: data.caller,
|
||||
|
|
@ -62,6 +59,9 @@ export class RunConversationTurnUseCase implements IRunConversationTurnUseCase {
|
|||
projectId,
|
||||
});
|
||||
|
||||
// assert and consume quota
|
||||
await this.usageQuotaPolicy.assertAndConsume(projectId);
|
||||
|
||||
// Check billing auth
|
||||
if (USE_BILLING) {
|
||||
// get billing customer id for project
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue