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

File cannot be renamed when using "prefix" option #193

Closed
zhousr2023 opened this issue Oct 22, 2024 · 11 comments · Fixed by #213
Closed

File cannot be renamed when using "prefix" option #193

zhousr2023 opened this issue Oct 22, 2024 · 11 comments · Fixed by #213
Assignees
Labels

Comments

@zhousr2023
Copy link

I use window to mount the webdav URL,I can create/delete/modify files normally.But I can't rename the file.When I rename file, the log tells me:

2024-10-22T13:30:12.942+0800    �[35mDEBUG�[0m  allowed & method & path {"allowed": false, "method": "MOVE", "path": "/m1GFBYH0uzjPPG/new_file.txt"}
2024-10-22T13:30:12.990+0800    �[34mINFO�[0m   user authorized {"username": "zhou", "remote_address": "[::1]:59048"}
2024-10-22T13:30:12.994+0800    �[35mDEBUG�[0m  allowed & method & path {"allowed": false, "method": "MOVE", "path": "/m1GFBYH0uzjPPG/new_file.txt"}
2024-10-22T13:30:13.863+0800    �[34mINFO�[0m   user authorized {"username": "zhou", "remote_address": "[::1]:59048"}
2024-10-22T13:30:13.866+0800    �[35mDEBUG�[0m  allowed & method & path {"allowed": false, "method": "MOVE", "path": "/m1GFBYH0uzjPPG/new_file.txt"}
2024-10-22T13:30:13.922+0800    �[34mINFO�[0m   user authorized {"username": "zhou", "remote_address": "[::1]:59048"}
2024-10-22T13:30:13.925+0800    �[35mDEBUG�[0m  allowed & method & path {"allowed": false, "method": "MOVE", "path": "/m1GFBYH0uzjPPG/new_file.txt"}
2024-10-22T13:30:13.969+0800    �[34mINFO�[0m   user authorized {"username": "zhou", "remote_address": "[::1]:59048"}
2024-10-22T13:30:13.971+0800    �[35mDEBUG�[0m  allowed & method & path {"allowed": false, "method": "MOVE", "path": "/m1GFBYH0uzjPPG/new_file.txt"}
2024-10-22T13:30:14.020+0800    �[34mINFO�[0m   user authorized {"username": "zhou", "remote_address": "[::1]:59048"}
2024-10-22T13:30:14.023+0800    �[35mDEBUG�[0m  allowed & method & path {"allowed": false, "method": "MOVE", "path": "/m1GFBYH0uzjPPG/new_file.txt"}

here is my configuration

address: 0.0.0.0
port: 6065

# TLS-related settings if you want to enable TLS directly.
tls: true
cert: cert.crt
key: key.key

# Prefix to apply to the WebDAV path-ing. Default is '/'.
prefix: /m1GFBYH0uzjPPG

# Enable or disable debug logging. Default is 'false'.
debug: true

# Disable sniffing the files to detect their content type. Default is 'false'.
noSniff: false

# Whether the server runs behind a trusted proxy or not. When this is true,
# the header X-Forwarded-For will be used for logging the remote addresses
# of logging attempts (if available).
behindProxy: false

# The directory that will be able to be accessed by the users when connecting.
# This directory will be used by users unless they have their own 'directory' defined.
# Default is '.' (current directory).
directory: D:\

# The default permissions for users. This is a case insensitive option. Possible
# permissions: C (Create), R (Read), U (Update), D (Delete). You can combine multiple
# permissions. For example, to allow to read and create, set "RC". Default is "R".
permissions: R

# The default permissions rules for users. Default is none.
rules: []

# Logging configuration
log:
  # Logging format ('console', 'json'). Default is 'console'.
  format: console
  # Enable or disable colors. Default is 'true'. Only applied if format is 'console'.
  colors: true
  # Logging outputs. You can have more than one output. Default is only 'stderr'.
  outputs:
  - stderr

# CORS configuration
cors:
  # Whether or not CORS configuration should be applied. Default is 'false'.
  enabled: false
  credentials: true
  allowed_headers:
    - Depth
  allowed_hosts:
    - http://localhost:8080
  allowed_methods:
    - GET
  exposed_headers:
    - Content-Length
    - Content-Range

# The list of users. If the list is empty, then there will be no authentication.
# Otherwise, basic authentication will automatically be configured.
#
# If you're delegating the authentication to a different service, you can proxy
# the username using basic authentication, and then disable webdav's password
# check using the option:
#
# noPassword: true
users:
  # Example 'admin' user with plaintext password.
  - username: zhou
    password: crypted
  # Example 'john' user with bcrypt encrypted password, with custom directory.
    rules:
     - permissions: CRUD

There is no permissions about MOVE, I don't know why.

@zhousr2023
Copy link
Author

Version is:

C:\Users\zhou\Downloads\windows-amd64-webdav>webdav.exe version
WebDAV version: 5.4.2

@hacdias
Copy link
Owner

hacdias commented Nov 9, 2024

Out of curiosity, where are you trying to move the file to?

Note: This may be some edge case mixing the prefix, directory and the permissions. Moving a file checks read and delete permissions at the source and create/update permissions at the destination.

@dmanbu
Copy link

dmanbu commented Nov 27, 2024

Out of curiosity, where are you trying to move the file to?

Note: This may be some edge case mixing the prefix, directory and the permissions. Moving a file checks read and delete permissions at the source and create/update permissions at the destination.

Just change the file name.
I also encountered the same problem

@hacdias
Copy link
Owner

hacdias commented Nov 28, 2024

I think I see the problem: it is probably a configuration problem. @zhousr2023 has the following configuration:

users:
  - username: zhou
    password: crypted
    rules:
     - permissions: CRUD

When defining rules, you have to indicate a path or a Regex pattern. The server startup should be failing in this case, because the rule is invalid. That is a bug, which I will fix.

If you want to set the global permissions for a user, you need to do it outside of the rules, which are only meant to be for a specific path or Regex pattern.

Try the following instead:

users:
  - username: zhou
    password: crypted
    permissions: CRUD

Let me know if this works. I will make a fix to ensure that the server actually fails validation of the rules if both the path and the regex are empty.

@lovitus
Copy link

lovitus commented Dec 31, 2024

I think I see the problem: it is probably a configuration problem. @zhousr2023 has the following configuration:

users:
  - username: zhou
    password: crypted
    rules:
     - permissions: CRUD

When defining rules, you have to indicate a path or a Regex pattern. The server startup should be failing in this case, because the rule is invalid. That is a bug, which I will fix.

If you want to set the global permissions for a user, you need to do it outside of the rules, which are only meant to be for a specific path or Regex pattern.

Try the following instead:

users:
  - username: zhou
    password: crypted
    permissions: CRUD

Let me know if this works. I will make a fix to ensure that the server actually fails validation of the rules if both the path and the regex are empty.

by this config

users:
  - username: zhou
    password: crypted
    permissions: CRUD

still cannot run MOVE command

image

@lovitus
Copy link

lovitus commented Dec 31, 2024

2024-12-31T15:32:17.218+0800 INFO user authorized {"username": "xxx", "remote_address": "11.5.103.71"}
2024-12-31T15:32:17.218+0800 DEBUG allowed & method & path {"allowed": true, "method": "MOVE", "path": "/webdav/index.html"}

@lovitus
Copy link

lovitus commented Dec 31, 2024

i use nginx proxy to this webdav server for ssl security .
is it the problem caused by the "Destination" parameter which auto generated when renaming a file

@lovitus
Copy link

lovitus commented Dec 31, 2024

image

try to expose the webdav service directly , still cannot make MOVE/RENAME operations.

@SamsidParty
Copy link

Yeah I also have this issue, I have custom code to modify the Destination header from the proxy but it still results in 404 errors.

Both macOS and Windows WebDAV clients have this error for me.

@hacdias hacdias changed the title I can't rename a file File cannot be renamed when using "prefix" option Jan 4, 2025
@hacdias hacdias self-assigned this Jan 4, 2025
@hacdias hacdias added the bug label Jan 4, 2025
@hacdias hacdias reopened this Jan 4, 2025
@hacdias
Copy link
Owner

hacdias commented Jan 4, 2025

This should be fixed in the new version: 5.7.1, which is being released now.

@lovitus
Copy link

lovitus commented Jan 4, 2025

This should be fixed in the new version: 5.7.1, which is being released now.

after updated to the latest version , problem has solved.

Thanks a lots for your hard work and sharing. Happy new year

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants