### Description This PR introduces an authorization layer for the post feature. It ensures that create, update, and read operations for posts are properly controlled based on user authentication status and post visibility (published vs. unpublished). #### Key Changes: * **Restricted Access to Unpublished Posts**: * Unauthenticated users can no longer access unpublished posts via the `GET /post/{id}` endpoint. Attempting to do so will now result in an `HTTP 401 Unauthorized` error. * The `get_all_post_info` endpoint is now aware of the user's authentication status to correctly filter posts. * **Authentication Required for Modifications**: * Creating (`POST /post`) and updating (`PUT /post/{id}`) posts now requires an authenticated user. The `user_id` is passed from the web handler through the controller to the use cases. * **New Error Type**: * A new `PostError::Unauthorized` variant has been added to handle access control failures gracefully. * **API & Core Logic Updates**: * The `PostController`, use cases (`GetFullPostUseCase`, `GetAllPostInfoUseCase`, etc.), and web handlers have been updated to accept and process the `user_id`. * The `GetFullPostUseCase` now contains the primary logic to prevent unauthenticated access to draft posts. * OpenAPI (Utopia) documentation has been updated to reflect these new authorization rules. ### Package Changes _No response_ ### Screenshots _No response_ ### Reference Resolves #119 ### Checklist - [x] A milestone is set - [x] The related issuse has been linked to this branch Reviewed-on: #124 Co-authored-by: SquidSpirit <squid@squidspirit.com> Co-committed-by: SquidSpirit <squid@squidspirit.com>
Backend
Development
SQL Migration
-
Install sqlx
cargo install sqlx-cli
-
Run migration
sqlx migrate run
Run Project
-
Prepare for sql schema setup
cargo sqlx prepare --workspace
-
Run the server
RUST_LOG=debug cargo run
-
(Optional) Hot restart
-
Install
watchexec
-
Run the server with
watchexec
RUST_LOG=debug watchexec -e rs -r 'cargo run'
-