POST /api/user/files/:id/password
Verify the password for a password-protected file. Upon successful verification, a cookie is set that allows access to the file for 60 seconds.This endpoint is rate-limited to 2 requests per second to prevent brute-force attacks.
Path Parameters
The file ID or file name to verify password for. Both the unique file ID (
clxyz123) and the file name on server (abc123.png) are accepted.Request Body
The password to verify for the file. Whitespace is automatically trimmed.
Response
Always
true when the password is correct. If incorrect, an error is returned instead.Example Request
Example Response
Cookies Set on Success
When the password is verified successfully, a cookie namedfile_pw_{fileId} is set with:
- Value: The verified password
- Max Age: 60 seconds
- HttpOnly:
false(accessible to JavaScript) - Secure:
false - SameSite:
lax - Path:
/
Error Responses
404 Not Found
- The file does not exist
- The file does not have password protection enabled
403 Forbidden
The provided password is incorrect.
429 Too Many Requests
Rate limit exceeded. You can only make 2 password verification attempts per second.
Security Features
- Rate Limiting: Limited to 2 requests per second to prevent brute-force attacks
- Password Hashing: Passwords are stored hashed in the database and verified using secure hashing
- Audit Logging: Both successful and failed password attempts are logged with:
- File name
- IP address
- User agent
- Timestamp
Use Case
This endpoint is typically used when:- A user tries to view a password-protected file
- The frontend prompts for a password
- The password is submitted to this endpoint
- If successful, the file can be accessed for the next 60 seconds
- After 60 seconds, the password must be re-entered