mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-30 23:40:40 +02:00
[PR #4027] [MERGED] fix(auth): Add admin-level auth to LibraryController 'delete', 'update' and 'delete items with issues' #4149
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/advplyr/audiobookshelf/pull/4027
Author: @Alexshch09
Created: 2/22/2025
Status: ✅ Merged
Merged: 2/23/2025
Merged by: @advplyr
Base:
master← Head:Add-admin-auth-to-LibraryController📝 Commits (1)
452d354fix(auth): Add admin-level auth to LibraryController delete update and issue removal📊 Changes
1 file changed (+15 additions, -0 deletions)
View changed files
📝
server/controllers/LibraryController.js(+15 -0)📄 Description
Brief summary
This PR addresses a security vulnerability in the LibraryController by enforcing admin-level authorization for critical endpoints that were previously accessible to non-admin users. Specifically, it restricts access to library settings updates, library issue removal, and library deletion to only admin users.
Which issue is fixed?
No issue reported (security fix).
In-depth Description
This PR implements admin-level authorization checks in the
LibraryControllerfor the following methods:PATCH /api/libraries/:id(update method): Previously, any authenticated user could potentially modify library settings. This change adds a check at the beginning of theupdatemethod to ensure that only users withisAdminOrUpprivileges can proceed with updating library settings.DELETE /api/libraries/:id/issues(removeLibraryItemsWithIssues method): Similarly, this endpoint for removing library items with issues was not properly protected. This PR adds anisAdminOrUpcheck at the start of theremoveLibraryItemsWithIssuesmethod to restrict its use to administrators.DELETE /api/libraries/:id(delete method): This PR also adds anisAdminOrUpcheck to thedeletemethod to ensure that only admin users can delete libraries. Deleting a library is a highly sensitive operation that should be restricted to administrators.These changes ensure that sensitive library management operations are only accessible to authorized admin users, enhancing the overall security and access control of the application.
How have you tested this?
Test Steps:
curlcommands to directly interact with the API endpoints.PATCH /api/libraries/:id:curlcommands were used with both Admin and Non-Admin JWTs to attempt updating library settings.DELETE /api/libraries/:id/issues:curlcommands were used with both Admin and Non-Admin JWTs to attempt removing library issues.DELETE /api/libraries/:id:curlcommands were used with both Admin and Non-Admin JWTs to attempt deleting a library.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.