- 
                Notifications
    
You must be signed in to change notification settings  - Fork 9
 
Feat: Implement file handling #93
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
base: master
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.
I guess all security concerns will come later.
| // | ||
| files := &files{} | ||
| v1restricted.POST("/files/valet-tokens", files.ValetTokens) | ||
| // Following endpoints are authorized via valet token | 
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.
So we should do something like:
v1valet := v1.Group("")
v1valet.Use(a valet middleware for authentication)
v1valet.POST("/files/upload/create-session", files.CreateUploadSession)
        
          
                internal/server/files.go
              
                Outdated
          
        
      | // TODO: Check format of fileId (Security) | ||
| // TODO: Allow custom path in config | ||
| // TODO: Subfolders for each user (Compatible format with official server) | ||
| return "/etc/standardfile/database/" + token.FileId | 
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.
Do we have the UserID somewhere to add one more namespace in the path?
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 UserID could be derived from token.Authorization.
Co-authored-by: mdouchement <marc.douchement@gmail.com>
| return nil, errors.New("Invalid path") | ||
| } | ||
| // TODO: Allow custom path in config | ||
| // TODO: Subfolders for each user (Compatible format with official server) | 
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.
go1.24 added https://pkg.go.dev/os#Root which helps to improve filesystem security.
I implemented support for file upload/download in Standard Notes and like to share my solution. Due to time issues some things are currently missing.
TODO:
FileIdby client is a valid UUIDv1valetmiddleware for authentication