Commit Graph

86 Commits

Author SHA1 Message Date
Georges-Antoine Assi
82ac766c9e oidc login using email 2024-12-12 10:08:27 -05:00
Georges-Antoine Assi
bc5c2e45f3 wokring oidc setup with authentik 2024-11-26 23:57:15 -05:00
Michael Manganiello
beeb9f0c31 misc: Create enum for authorization scopes
Instead of using just strings, this change converts the scopes to a
`StrEnum`, to be compatible with places where a string is expected. This
avoids typos when using these scopes, simplifies searching for usages,
and improves type hints.

An extra change was the fix to the Firmware download endpoint, which
wasn't respecting the `DISABLE_DOWNLOAD_ENDPOINT_AUTH` flag.
2024-10-18 23:57:42 -03:00
Michael Manganiello
eba2971ffb fix: Simplify query that validates new username already exists
Instead of fetching all users and checking if the new username is present
in the list, we can directly query the database for the username.
2024-10-14 01:10:31 -03:00
Michael Manganiello
1df27079c4 fix: Avoid query during import time to set add_user endpoint scopes
The `add_user` endpoint was querying the database at import time, to
decide whether to enforce the `users.write` scope or not. This is
problematic because the database might not be ready at import time.

Also, the decided `scopes` was being maintained for the entire
application lifetime, which is not ideal, as users can be created
without having the `users.write` scope, until the application is
restarted.
2024-10-13 22:27:14 -03:00
SaraVieira
9b298d46eb use env & reuse request 2024-09-10 21:00:20 +01:00
SaraVieira
dc3a363bf2 finish endpoint; add final FE 2024-09-04 23:29:15 +01:00
SaraVieira
3070b7e9be use data from db 2024-09-04 18:09:33 +01:00
Michael Manganiello
8abbae4c02 misc: Make backend handle URLs with trailing slash
According to multiple FastAPI discussions [1], FastAPI only includes a
built-in mechanism to redirect requests including a trailing slash, to
its variation without slash, using a `307` status code.

This can be an issue when certain clients do not send the same headers
on the redirected request.

This change adds a custom FastAPI `APIRouter`, that registers both route
path variations (with and without trailing slash), while only marking
the path without slash for being included in the OpenAPI schema.

[1] https://github.com/fastapi/fastapi/discussions/7298
2024-08-07 00:22:21 -03:00
Michael Manganiello
749e4d65c1 misc: Use PYTEST_VERSION variable to detect Pytest runs
Pytest v8.2 introduced the `PYTEST_VERSION` environment variable [1],
that can be used to check if code is running from within a pytest run.

This way, we can avoid checking the loaded `sys` modules.

[1] https://docs.pytest.org/en/stable/changelog.html#id57
2024-07-27 12:03:44 -03:00
Michael Manganiello
d1fda9081f fix: Add missing awaits on read/write for async opened files 2024-07-27 00:38:05 -03:00
Michael Manganiello
c5b150c1eb fix: Enable flake8-async rules in ruff and fix warnings
`ASYNC` rules [1] tries to find issues regarding asynchronous code. This
change enables `ruff` to start reporting these issues, and fixes
existing warnings.

[1] https://docs.astral.sh/ruff/rules/#flake8-async-async
2024-07-26 21:40:46 -03:00
zurdi
1a3f74e8ac check username already exists on setup wizard 2024-07-08 11:56:10 +02:00
Zurdi
14e2377f3a fixes from PR review 2024-07-06 18:55:45 +02:00
Zurdi
4435093329 Update backend/endpoints/user.py
Co-authored-by: Georges-Antoine Assi <3247106+gantoine@users.noreply.github.com>
2024-07-06 18:53:29 +02:00
Zurdi
e9c33043e5 Merge branch 'master' into feature/user-own-edit 2024-07-06 18:41:55 +02:00
Zurdi
ca7d37a3b0 fixed unit tests 2024-07-06 17:40:13 +02:00
Zurdi
eda1c94868 fixed user endpoint tests 2024-07-05 19:16:47 +02:00
zurdi
9ff5eeb367 modified update user endpoint to allow own edition 2024-07-04 21:19:20 +02:00
zurdi
2ec4debd61 setup wizard added 2024-07-04 14:19:00 +02:00
Georges-Antoine Assi
880345f20c ruff-only pre-commit 2024-05-18 12:05:57 -04:00
Georges-Antoine Assi
2749aaee4a rename back to old names 2024-05-05 16:59:30 -04:00
Georges-Antoine Assi
9ad28f3294 more refactoring again 2024-05-05 16:32:40 -04:00
Georges-Antoine Assi
def2608c28 refactor db handlers 2024-05-05 15:46:07 -04:00
Georges-Antoine Assi
1a2c914045 refactor handlers out into own files 2024-05-05 12:45:56 -04:00
Georges-Antoine Assi
07cc82b627 Fix auth handling on user update 2024-03-06 09:53:29 -05:00
Georges-Antoine Assi
7ca551b743 switched to jwt backed sessions 2024-02-16 10:00:54 -05:00
Zurdi
1e9dac9eeb clean up user avatar code 2024-02-10 17:10:24 +01:00
Zurdi
e226a06531 create avatar path if not exists 2024-02-10 12:46:45 +01:00
Zurdi
0b3b353937 fixed user custom avatar location 2024-02-09 12:51:52 +01:00
Georges-Antoine Assi
6bcadec702 everything we need for 3.0 2024-02-01 18:13:16 -05:00
Georges-Antoine Assi
eb18388a81 Mega refactor of asset 2024-02-01 17:59:06 -05:00
Georges-Antoine Assi
81b5bcf9ba refactor handler names 2024-01-18 14:04:35 -05:00
Georges-Antoine Assi
9495942084 Fix the rest of the tests 2024-01-17 10:57:07 -05:00
Zurdi
0af3ffb86f refactor stats and user handlers 2024-01-17 01:43:16 +01:00
Zurdi
42065aec7c backend refactor as RESTful 2024-01-15 13:34:18 +01:00