Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
♻️ Add API key scopes for user
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Nov 8, 2020
1 parent bf9976d commit c84bccb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/modules/api-keys/api-keys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,23 @@ export class ApiKeysService {
] = `Delete subnet: ${subnet.subnet}`;
}

scopes[`user-${userId}:write-api-key-*`] = 'Create and update API keys';
scopes[`user-${userId}:read-api-key-*`] = 'Read API keys';
for await (const apiKey of await this.prisma.apiKeys.findMany({
where: { user: { id: userId } },
select: { id: true, name: true, apiKey: true },
})) {
scopes[`user-${userId}:read-api-key-${apiKey.id}`] = `Read API key: ${
apiKey.name ?? apiKey.apiKey
}`;
scopes[`user-${userId}:write-api-key-${apiKey.id}`] = `Write API key: ${
apiKey.name ?? apiKey.apiKey
}`;
scopes[`user-${userId}:delete-api-key-${apiKey.id}`] = `Delete API key: ${
apiKey.name ?? apiKey.apiKey
}`;
}

scopes[`user-${userId}:delete-mfa-*`] =
'Disable multi-factor authentication';
scopes[`user-${userId}:write-mfa-regenerate`] =
Expand Down

0 comments on commit c84bccb

Please sign in to comment.