* Do path joins more safely
* Improve path cleaning and tests
* Lower-case error message
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* Correct handle potential errors in `get_path`
* Use `expect` in tests, rather than `unwrap`
* Correctly handle invalid upload path without panic
* Correctly handle filesystem create errors
* Use result rather than option to allow easier error handling
---------
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* refactor!: use `actix-web-grants` to protect endpoints
* fix: filter out blank strings
* doc: add documentation for a function
* fix: don't return body for not exposed endpoints
* test: add fixtures
* test: fix naming
* test: remove extra step in teardown
* feat(log): use 'tracing-subscriber' instead of 'env_logger'
resolves#161
* feat: use 'tracing' instead of 'log'
* feat: make 'INFO' the default log level
* Delete endpoint implementation with delete_tokens configuration
* style(server): remove empty line, add dot at end of doc comment
* test(fixtures): add fixture test for file delete
* refactor(config): add delete_tokens to config.toml
* docs(readme): add info on how to delete file from server
* Update README.md
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* Update README.md
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* refactor(server): use log::error! and return 500
Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>
* test(server): add test_delete_file_without_token_in_config
* refactor(server): use one function to retrieve auth/delete tokens
Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>
* test(config): add test_get_tokens
* test(config): improve test_get_tokens
* feat(config): disallow empty tokens
* feat(server): update the messages for delete endpoint
---------
Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* feat(server): add url encoding
- Introduced an option to enable encoding for filenames in the returned URL.
- Modified the encoding approach to specifically target whitespaces, replacing them with `%20`.
- Included unit tests to validate this encoding approach.
- Added fixture tests for broader functional verification.
- Removed the `urlencoding` dependency from `Cargo.toml`.
* Refactor code and fixtures for better compliance and consistency
- Fixed errors in the fixture configuration to ensure tests run as expected.
- Reformatted line endings for consistency across the codebase.
- Made necessary adjustments to adhere to Clippy's recommendations.
* Enhance whitespace handling options for filenames
- Implemented a configuration choice for space handling in filenames: encode, replace with underscores or none.
- Added corresponding unit and fixture tests.
* Remove redundant function call
Fixed misplaced line as per @tessus's review feedback, preventing duplicate handling of spaces in filenames.
* Delete test file with spaces.txt
* Refactor filename space handling
- Introduced `SpaceHandling` enum to manage filename spaces.
- Updated server.rs and paste.rs to utilize the new method.
- Added unit tests for the new filename handling method.
- Adjusted fixture tests to reflect these changes.
* Move filename processing into `SpaceHandling` enum
- Relocated filename processing logic to reside within the `SpaceHandling` enum, enhancing encapsulation.
- Updated calls in `server.rs` and `paste.rs` to use the new method structure.
- Adjusted unit tests to align with the refactored function location and call pattern.
* Refactor based on review suggestions
- Incorporated the inline suggestions made by @tessus, removing the unnecessary one-line assignments.
- Ensured the code adheres to Rust guidelines by running clippy and fmt.
* chore(deps): revert changes in Cargo.lock
* chore(config): replace spaces as default
* refactor(config): move SpaceHandling to config module
---------
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* fix(server): do not list expired files
* refactor(server): simplify list files function
* add test case
---------
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* Start
* Wip
* Implement path based JSON index
* Remove json_index_path
* Return datetime stamp instead of relative time
* Add file size to list item
* Add auth check when retrieving JSON index
* Make json index path hardcoded
* Test (currently failing)
* Fix test for test_json_list
* Clippy fix
* Revert cargo to original versions with only needed changes
* Add detail about auth guard affecting list route
* Change json_index_path to expose_list
* Remove unneeded linebreak
* Remove unnecessary import
* Remove unnecessary space at end of line
* Move config check after auth check
* Use new auth check syntax, add docs to struct, rename test_json_list to test_list
* Replace chrono usage with uts2ts
* Check list result in test
* Add example to README
* Upgrade serde_json to 1.0.103
* Add linebreak
* Remove unneeded clone
* Remove extra nl
* Update README.md
* Update README.md
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* Update README.md
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* Remove serde_json
* Set default config to false for expose_list
* Apply suggestions from code review
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* Check that option is value in test_list
* Update Cargo.toml
Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>
* Update cargo.lock
* Use expect() to check file name
* Remove underscore from list item struct
* Keep comma after last line
* refactor(server): rename ListItem fields
* test(fixtures): add fixture test for listing files
* test push
* remove file again
* chop off ts from filename and minor refactor
* update README
* docs(readme): fix capitalization
* refactor(server): clean up list implementation
---------
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>
* feat(server): support multiple auth tokens
Example:
```toml
[server]
auth_tokens = [
"super_secret_token1",
"super_secret_token2",
]
```
The previously used `AUTH_TOKEN` environment variable can still be used
and will be evaluated as well.
* fixtures: add all tokens in array to the test
* add deprecation warning for auth_token
* also add deprecation warnings at server startup
* fix formatting
* fixed tests, so that we do not use deprecated config options
* use bash array
* refactor: use separate function
* refactor: check auth tokens
* Update fixtures/test-server-auth-multiple-tokens/test.sh
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* refactor: convert functions to methods
* refactor: check function
* refactor: get_tokens method
* style(format): add newline between functions
* refactor(server): print deprecation warnings once
---------
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
This is a hotfix commit which allows the use of [server.landing_page]
fields even when the [landing_page] section does not exist in the
configuration file.
* add random suffix mode
* fix linter issues
* add test case
* fix linter issues
* add comments, remove empty lines and single line declarations
* more test cases
* refactor(config): rename suffix_mode to random_suffix
* refactor(paste): clean up the random suffix logic
* chore(config): add random suffix example to default config
* docs(readme): mention random suffix feature
* test(fixtures): add fixture test for random suffix mode
* random_suffix -> suffix_mode
* fix default extension for .dotfile w/o extension
* fix formatting
* style(format): fix the indentation for random suffix fixture
---------
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* honor X-Forward-* headers
Behind a reverse proxy, the log entries always showed the IP address of the reverse proxy.
With this change the real IP address of the client is shown.
Since the IP address is only used for info in the log, there are no security implications.
* style(format): apply formatting
---------
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* feat(deploy): deploy on shuttle.rs
* chore(deploy): add automated shuttle deploy workflow
* style(readme): update the formatting in README.md
* chore(deploy): optimize shuttle workflow
* fix(deploy): start the project
* fix(deploy): remove start step
This reverts commit 4f25921aeb.
* chore(deploy): expose the version for the public instance
* docs(lib): update the comment for shuttle entry-point
* chore(deploy): run the shuttle deployment on new tag