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

Feat: Implement file handling #93

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Crusader99
Copy link
Contributor

@Crusader99 Crusader99 commented Nov 3, 2022

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:

  • Use sub folders for each user to prevent conflicts
  • Security: Check provided FileId by client is a valid UUID
  • Add v1valet middleware for authentication
  • Integration tests are currently missing and should be added
  • Allow to configure a custom folder path in config

Copy link
Owner

@mdouchement mdouchement left a 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
Copy link
Owner

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 Show resolved Hide resolved
internal/server/files.go Show resolved Hide resolved
// 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
Copy link
Owner

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?

Copy link
Contributor Author

@Crusader99 Crusader99 Nov 3, 2022

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.

internal/server/files.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants