-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat: files visiblity with file configuration #10438
base: main
Are you sure you want to change the base?
feat: files visiblity with file configuration #10438
Conversation
Sorry for the merges. Forgot to check my git global config :) |
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.
PR Summary
This PR implements file visibility configuration to handle public assets like workspace logos, particularly addressing token expiration issues in emails.
- Added
FileFolderConfig
type infile-folder.interface.ts
withisPublic
flag to control folder accessibility - Modified
FilePathGuard
to ignore token expiration for public folders while maintaining workspaceId validation - Added
checkFileFolder
utility function to validate folder paths, though with some redundant logic - Improved board column layout by repositioning the 'new record' button outside draggable components
💡 (2/5) Greptile learns from your feedback when you react with 👍/👎!
4 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile
export const checkFileFolder = (filePath: string): FileFolder => { | ||
const allowedFolders = Object.values(FileFolder).map((value) => | ||
kebabCase(value), | ||
); | ||
|
||
const sanitizedFilePath = filePath.replace(/\0/g, ''); | ||
const [rootFolder] = sanitizedFilePath.split('/'); | ||
|
||
if (!allowedFolders.includes(rootFolder as AllowedFolders)) { | ||
throw new BadRequestException(`Folder ${rootFolder} is not allowed`); | ||
} | ||
|
||
return rootFolder as FileFolder; | ||
}; |
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.
style: Duplicates folder validation logic from checkFilePath. Consider extracting common validation into a shared function.
); | ||
|
||
const sanitizedFilePath = filePath.replace(/\0/g, ''); | ||
const [rootFolder] = sanitizedFilePath.split('/'); |
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.
logic: No validation for empty filePath or malformed paths that could cause rootFolder to be undefined
const [rootFolder] = sanitizedFilePath.split('/'); | |
if (!sanitizedFilePath) { | |
throw new BadRequestException('File path cannot be empty'); | |
} | |
const [rootFolder] = sanitizedFilePath.split('/'); | |
if (!rootFolder) { | |
throw new BadRequestException('Invalid file path format'); | |
} |
if (!query || !query['token']) { | ||
return false; | ||
} |
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.
logic: Still requiring token for public folders negates the purpose of making them public. Consider removing token requirement for public folders entirely.
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.
Currently the workspaceId
which is required to fetch the images is in the token. So this is not feasible currently
packages/twenty-server/src/engine/core-modules/file/guards/file-path-guard.ts
Show resolved
Hide resolved
5a0d3f7
to
7382713
Compare
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.
PR Summary
This PR refines the file visibility implementation by adding proper type definitions and folder configurations for public and private file access.
- Introduced
FileFolderConfig
type withisPublic
boolean flag in/packages/twenty-server/src/engine/core-modules/file/interfaces/file-folder.interface.ts
- Configured public access for
ProfilePicture
,WorkspaceLogo
, andPersonPicture
folders while keepingAttachment
andServerlessFunction
private - Potential security concern:
FilePathGuard
still requires tokens for public folders, which seems unnecessary and could be simplified
3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
throw new BadRequestException(`Folder ${rootFolder} is not allowed`); | ||
} | ||
|
||
return rootFolder as FileFolder; |
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.
logic: Type casting to FileFolder may fail at runtime if rootFolder is kebab-cased. Need to reverse the kebab case transformation.
c3199a2
to
c33b248
Compare
Ref: #10404
FileFolderConfig
withisPublic
key.file-path-guard.ts
toignoreExpiration
to validate the token ifisPublic
istrue
.workspaceId
.