torrust / torrust-index

This repository serves as the backend for the Torrust Index project.
https://torrust.com
GNU Affero General Public License v3.0
50 stars 19 forks source link

Fix unhandled errors on maybe_user_id unwraps in authorization logic #709

Closed mario-nt closed 1 month ago

mario-nt commented 1 month ago

There are several unwraps that lack error handling in the authorization logic when unwrapping the maybe_user_id variable, this PR fix that by handling the errors.

mario-nt commented 1 month ago

@josecelano Maybe we can still use the user_id extractor in the handler or move that logic to the service:

Also we need to find a way to not allow those policies as they break the expected behavior of the app and might even lead to a security risk.

Actually, right now, the authorization policy is coupled with the logic in the handlers and services, maybe we should not allow end user to modify Casbin policies directly, only certain things like users and roles, and then persist those settings into the Casbin policy. All those customization options should be constrained and decided before hand.

josecelano commented 1 month ago

ACK 2e4b8d61d5b972eedae4615f70958560d43a810e