Skip to content

Commit

Permalink
fix: organization_invitation.deleted event and set auditableType (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech authored Jan 17, 2024
1 parent c96e5ee commit be4e38b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 14 additions & 3 deletions controlplane/src/core/bufservices/PlatformService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1603,10 +1603,10 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
targetId: graph.id,
targetDisplayName: graph.name,
targetType: 'federated_graph',
auditableType: 'graph_token',
actorDisplayName: authContext.userDisplayName,
actorType: authContext.auth === 'api_key' ? 'api_key' : 'user',
auditableDisplayName: token.name,
auditableType: 'graph_token',
});

return {
Expand Down Expand Up @@ -1718,6 +1718,7 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
action: 'created',
actorId: authContext.userId,
auditableDisplayName: req.email,
auditableType: 'user',
actorDisplayName: authContext.userDisplayName,
actorType: authContext.auth === 'api_key' ? 'api_key' : 'user',
});
Expand Down Expand Up @@ -1785,6 +1786,7 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
action: 'created',
actorId: authContext.userId,
auditableDisplayName: req.email,
auditableType: 'user',
actorDisplayName: authContext.userDisplayName,
actorType: authContext.auth === 'api_key' ? 'api_key' : 'user',
});
Expand Down Expand Up @@ -2092,6 +2094,7 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
action: 'deleted',
actorId: authContext.userId,
auditableDisplayName: req.email,
auditableType: 'user',
actorDisplayName: authContext.userDisplayName,
actorType: authContext.auth === 'api_key' ? 'api_key' : 'user',
});
Expand Down Expand Up @@ -2185,8 +2188,11 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
auditAction: 'organization_invitation.deleted',
action: 'deleted',
actorId: authContext.userId,
auditableDisplayName: org.name,
auditableDisplayName: user.email,
auditableType: 'user',
actorDisplayName: authContext.userDisplayName,
targetDisplayName: org.name,
targetType: 'organization',
actorType: authContext.auth === 'api_key' ? 'api_key' : 'user',
});

Expand Down Expand Up @@ -3009,6 +3015,7 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
action: 'updated',
actorId: authContext.userId,
auditableDisplayName: 'admin',
auditableType: 'member_role',
actorDisplayName: authContext.userDisplayName,
targetId: orgMember.userID,
targetDisplayName: orgMember.email,
Expand Down Expand Up @@ -3042,8 +3049,10 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
action: 'updated',
actorId: authContext.userId,
auditableDisplayName: role,
auditableType: 'member_role',
actorDisplayName: authContext.userDisplayName,
targetId: orgMember.userID,
targetType: 'user',
targetDisplayName: orgMember.email,
actorType: authContext.auth === 'api_key' ? 'api_key' : 'user',
});
Expand Down Expand Up @@ -3117,10 +3126,10 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
targetId: federatedGraph.id,
targetDisplayName: federatedGraph.name,
targetType: 'federated_graph',
auditableType: 'graph_token',
actorDisplayName: authContext.userDisplayName,
actorType: authContext.auth === 'api_key' ? 'api_key' : 'user',
auditableDisplayName: currToken.name,
auditableType: 'graph_token',
});

return {
Expand Down Expand Up @@ -3688,6 +3697,7 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
action: 'joined',
actorId: authContext.userId,
auditableDisplayName: organization.name,
auditableType: 'organization',
actorDisplayName: authContext.userDisplayName,
actorType: authContext.auth === 'api_key' ? 'api_key' : 'user',
});
Expand All @@ -3700,6 +3710,7 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
action: 'deleted',
actorId: authContext.userId,
auditableDisplayName: organization.name,
auditableType: 'organization',
actorDisplayName: authContext.userDisplayName,
actorType: authContext.auth === 'api_key' ? 'api_key' : 'user',
});
Expand Down
4 changes: 3 additions & 1 deletion controlplane/src/db/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ export type AuditableType =
| 'api_key'
| 'webhook_config'
| 'integration'
| 'member_role'
| 'user'
| 'subscription';

export type AuditTargetType = 'organization' | 'subgraph' | 'federated_graph';
export type AuditTargetType = 'organization' | 'subgraph' | 'federated_graph' | 'user';

export type AuditActorType = 'user' | 'system' | 'api_key';

Expand Down

0 comments on commit be4e38b

Please sign in to comment.