Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/commands/subgraph/commands/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default (opts: BaseCommandOptions) => {
const deletionConfirmed = await inquirer.prompt({
name: 'confirmDeletion',
type: 'confirm',
message: 'Are you sure you want to delete this federated graph?',
message: 'Are you sure you want to delete this subgraph?',
});
if (!deletionConfirmed.confirmDeletion) {
process.exit(1);
Expand Down
14 changes: 14 additions & 0 deletions controlplane/src/core/bufservices/PlatformService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,20 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
};
}

const userRoles = await orgRepo.getOrganizationMemberRoles({
userID: authContext.userId || '',
organizationID: authContext.organizationId,
});

if (!(apiKey.creatorUserID === authContext.userId || userRoles.includes('admin'))) {
return {
response: {
code: EnumStatusCode.ERR,
details: `You are not authorized to delete the api key '${apiKey.name}'`,
},
};
}

await orgRepo.removeAPIKey({
name: req.name,
organizationID: authContext.organizationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export class OrganizationRepository {
lastUsedAt: apiKeys.lastUsedAt,
expiresAt: apiKeys.expiresAt,
createdBy: users.email,
creatorUserID: users.id,
})
.from(apiKeys)
.innerJoin(users, eq(users.id, apiKeys.userId))
Expand All @@ -316,6 +317,7 @@ export class OrganizationRepository {
lastUsedAt: key[0].lastUsedAt?.toISOString() ?? '',
expiresAt: key[0].expiresAt?.toISOString() ?? '',
createdBy: key[0].createdBy,
creatorUserID: key[0].creatorUserID,
} as APIKeyDTO;
}

Expand All @@ -328,10 +330,12 @@ export class OrganizationRepository {
lastUsedAt: apiKeys.lastUsedAt,
expiresAt: apiKeys.expiresAt,
createdBy: users.email,
creatorUserID: users.id,
})
.from(apiKeys)
.innerJoin(users, eq(users.id, apiKeys.userId))
.where(eq(apiKeys.organizationId, input.organizationID))
.orderBy(asc(apiKeys.createdAt))
.execute();

return keys.map(
Expand All @@ -343,6 +347,7 @@ export class OrganizationRepository {
lastUsedAt: key.lastUsedAt?.toISOString() ?? '',
expiresAt: key.expiresAt?.toISOString() ?? '',
createdBy: key.createdBy,
creatorUserID: key.creatorUserID,
} as APIKeyDTO),
);
}
Expand Down
1 change: 1 addition & 0 deletions controlplane/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export interface APIKeyDTO {
lastUsedAt: string;
expiresAt: string;
createdBy: string;
creatorUserID: string;
}

export interface ResponseMessage {
Expand Down
1 change: 0 additions & 1 deletion controlplane/test/composition-errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ describe('CompositionErrors', (ctx) => {
};

const result = composeSubgraphs([subgraph1, subgraph2]);
console.log(result);

expect(result.errors).toBeDefined();
expect(result.errors?.[0].message).toBe(
Expand Down
3 changes: 2 additions & 1 deletion keycloak/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
theme/target
**/node_modules
**/node_modules
theme/.parcel-cache
Loading