Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: feat: add permission check #395

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
15 changes: 6 additions & 9 deletions src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import express from "express";

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

Declaration or statement expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

Declaration or statement expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

'try' expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

Identifier expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

';' expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

Declaration or statement expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

Declaration or statement expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

Declaration or statement expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

'try' expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

Identifier expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

';' expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

Declaration or statement expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

Declaration or statement expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

Declaration or statement expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

'try' expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

Identifier expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

';' expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (16.x)

Declaration or statement expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

Declaration or statement expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

Declaration or statement expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

'try' expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

Identifier expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

';' expected.

Check failure on line 1 in src/auth.ts

View workflow job for this annotation

GitHub Actions / Test Build (18.x)

Declaration or statement expected.
import { config } from "./common/config";
import * as fs from "fs";
import jwtLib from "jsonwebtoken";
Expand Down Expand Up @@ -91,15 +91,12 @@



const valid = await dataSetAPI.datasetsControllerFindById({pid: authRequest.dataset}).then(
(value) =>
{
if(value.isPublished || // Check if proposal is public
value.accessGroups.some(item => new Set(authRequest.jwt.groups).has(item)) || // Check if user has one or more of the access groups of dataset
authRequest.jwt.groups.indexOf(value.ownerGroup) > -1) //Check if user has the owner group
{
return true;
}
const isPublic = value.isPublished;
const hasAccessGroup = value.accessGroups.some(item => new Set(authRequest.jwt.groups).has(item));
const hasOwnerGroup = authRequest.jwt.groups.includes(value.ownerGroup);
if (isPublic || hasAccessGroup || hasOwnerGroup) {
return true;
}
Comment on lines +94 to +99
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is value coming from?


return false;

Expand Down
Loading