All checks were successful
Frontend CI / build (push) Successful in 1m8s
### Description This PR introduces a generic authentication middleware to protect application routes. The primary goal is to prevent unauthenticated users from uploading images. #### Changes Implemented * **Authentication Middleware**: * Created a new `auth_middleware` that checks the user's session for a valid `user_id`. * If a `user_id` exists, it's added to the request extensions, making it available to downstream handlers. * **`UserId` Extractor**: * A `UserId` type that implements `FromRequest` has been added. * This allows route handlers to declaratively require authentication by simply adding `user_id: UserId` as a parameter. If the user is not logged in, the extractor automatically returns an `ErrorUnauthorized` response. * **Route Protection**: * The `upload_image_handler` now includes the `UserId` extractor, securing the endpoint. * A new `/auth/me` route has been added for easily verifying the logged-in user's ID during development and testing. * **Minor Refinements**: * The `logout_handler` now uses `session.clear()` for more robust session termination. * Corrected the default Redis URL from `redis://127.0.1:6379` to `redis://127.0.0.1:6379`. ### Package Changes _No response_ ### Screenshots _No response_ ### Reference Resolves #86 ### Checklist - [x] A milestone is set - [x] The related issuse has been linked to this branch Reviewed-on: #101 Co-authored-by: SquidSpirit <squid@squidspirit.com> Co-committed-by: SquidSpirit <squid@squidspirit.com>
16 lines
294 B
TOML
16 lines
294 B
TOML
[package]
|
|
name = "image"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
|
|
[dependencies]
|
|
actix-multipart.workspace = true
|
|
actix-web.workspace = true
|
|
async-trait.workspace = true
|
|
futures.workspace = true
|
|
log.workspace = true
|
|
serde.workspace = true
|
|
sqlx.workspace = true
|
|
|
|
auth.workspace = true
|