-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should try to unify the configuration in a single file or at least a single methodology.
directory: config.testData.directory || "", | ||
dataset: "", | ||
file0: config.testData?.files[0] || "", | ||
file1: config.testData?.files[1] || "", | ||
file2: config.testData?.files[2] || "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current configuration allows to download files only from a single dataset.
Should we consider to change the data structure here to allow multi dataset, multi files download?
Or should we keep it as it is in this PR and consider it for future a one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where in SciCat can you download files from multiple datasets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at the moment, but it is coming
src/auth.ts
Outdated
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; | |
} |
It'd be easier to read this way, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested codes should be inside the curly bracket.
Co-authored-by: Jay <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New changes make the logic clear, but it is not clear the origin of the values used to test
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; | ||
} |
There was a problem hiding this comment.
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?
Should not be merged until final package of sdk-typescript for scicat is released