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

Commit

Permalink
🐛 Fix authorization of API keys
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Jun 22, 2019
1 parent 20009b7 commit 5edab54
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "staart",
"version": "1.0.29",
"version": "1.0.30",
"main": "index.js",
"repository": "[email protected]:AnandChowdhary/staart.git",
"author": "Anand Chowdhary <[email protected]>",
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ const canUserOrganization = async (
// An organization manager can do anything but delete
if (
membership.role == MembershipRole.MANAGER &&
action != Authorizations.DELETE
action != Authorizations.DELETE &&
action != Authorizations.DELETE_SECURE
)
allowed = true;

Expand Down
9 changes: 8 additions & 1 deletion src/rest/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,14 @@ export const createApiKeyForUser = async (
access: ApiKeyAccess,
locals: Locals
) => {
if (await can(userId, Authorizations.CREATE_SECURE, "user", organizationId)) {
if (
await can(
userId,
Authorizations.CREATE_SECURE,
"organization",
organizationId
)
) {
const apiKey = await createApiKey({ organizationId, access });
await createEvent(
{
Expand Down

0 comments on commit 5edab54

Please sign in to comment.