Commit Graph

100 Commits

Author SHA1 Message Date
Manuel Raynaud
4d2d924768 (marketing) add documentation
Add documentation explainig how to use this module and how to add a new
backend.
2025-12-08 15:03:18 +01:00
Manuel Raynaud
6b1d47b80d (marketing) create a celery task to create a new contact
To ease the use of this module, we added a shared task which a wrapper
arount the configured backend and will only call the
create_or_update_contact in a celery task.
2025-12-08 15:03:18 +01:00
Manuel Raynaud
609251233a (marketing) implement brevo backend
Brevo is the first real backend we have to implement. The init method is
reposible to configure it.
2025-12-08 15:03:18 +01:00
Manuel Raynaud
48094c2eb8 (marketing) create tooling to help backend initialization
Like we did for the malware_detection module, we want helpers allowing
use to instantiate a backend without knowing in the code how to do it,
just importing a module and the marketing service is ready to be used.
2025-12-08 15:03:18 +01:00
Manuel Raynaud
d326b643e5 (marketing) create a dummy backend
We create first a dummy backend doing nothing allowing us to use later
some helpers without configuring a real backend.
2025-12-08 15:03:18 +01:00
Manuel Raynaud
879a153d90 (marketing) create marketing backend abstraction
Marteking backends will have to implement an abstract base backend in
order to be able to not be dependant from only one implementation
2025-12-08 15:03:18 +01:00
Manuel Raynaud
7e88f9d111 👷(action) add python 3.14 in tests suite
We want to test the library with python 3.14. We update the tox.ini
confiration file and add python 3.14 to the test-back matric.
2025-12-08 15:01:17 +01:00
Manuel Raynaud
33c1839e93 🔖(patch) bump release to 0.0.21
Added

- (malware) save file hash in detection record and callback
v0.0.21
2025-12-04 16:10:15 +01:00
Manuel Raynaud
4e269ac854 (malware) display the file_hash in read only in the admin panel
We want to see the file_hash in the admin panel, this field is in read
only and it is possible to search a file_hash
2025-12-04 16:10:15 +01:00
Manuel Raynaud
f230d027ef (malware) save file hash in detection record and callback
The file hash is a crucial info. We save it in database if a record
exists but also transmit it to the callback in the error_info.
2025-12-04 16:10:15 +01:00
Manuel Raynaud
5df4b8f24b 🔖(patch) bump release to 0.0.20
Added

- (backend) keep traces of failed malware analysis tasks
- (backend) save backend used in a malware analysis task
- (backend) allow a malware detection backend to reschedule a task
- (malware) add management command to reschedule processing
- (malware) add an admin view to ease tracking tasks
v0.0.20
2025-12-02 09:31:29 +01:00
Manuel Raynaud
79e1fecba3 (malware) admin action to reschedule tasks
We add an admin action allowing to reschedule a task from the list view
2025-12-02 09:31:29 +01:00
Manuel Raynaud
00e66992e8 (malware) add an admin view to ease tracking tasks
We want to more easily track tasks, we added an admin view. For now this
admin view only list all existing tasks in the database.
2025-12-02 09:31:29 +01:00
Manuel Raynaud
3bdfdf2b16 ♻️(malware) log filehash when a submission fail
We want to log the file has when a submission fail in order to aggregate
all this logs to send them to JCOP.
2025-12-02 09:31:29 +01:00
Manuel Raynaud
b0b90be8fe (malware) add management command to reschedule processing
We want to reschedule processing task when they are older than 3 days.
A settings is used to modify this delay. The current backend is
instanciated and it is the backend responsability to determine if it
should reschedule it or not.
2025-12-02 09:31:29 +01:00
Manuel Raynaud
98c0510f6d (malware) add frezzegun dependency
In a future test we will need to control the datetime, we install the
freezegun library for this.
2025-12-02 09:31:29 +01:00
Manuel Raynaud
519f58ea8a (malware) allow a malware detection backend to reschedule a task
For multiple reasons a task can be blocked in processing task. We wanto
to allow a backend to reschedule a blocked task.
2025-12-02 09:31:29 +01:00
Manuel Raynaud
3d86ec7e4e (malware) save backend used in a malware analysis task
For later use we wan't to know the backend used for a given task
2025-12-02 09:31:29 +01:00
Manuel Raynaud
a91ad0009e (malware) keep traces of failed malware analysis tasks
We want to keep in the database the failed tasks with the reason why
they failed. The idea is to take a decision later on what to do for
tasks reaching a max retries for example.
2025-12-02 09:31:29 +01:00
Quentin BEY
6947c146a4 🔖(patch) bump release to 0.0.19
Changed

- ♻️(resource-server) make token introspection earlier #46
v0.0.19
2025-11-21 16:46:44 +01:00
Quentin BEY
c4e82df906 🐛(resource-server) do not load OIDC backend at initialization
The previous code was loading the `get_oidc_backend` before
override it after. Loading loading an unused backend is a
waste of resource ^^

While the default OIDC backend requires
more settings, like `OIDC_FALLBACK_TO_EMAIL_FOR_IDENTIFICATION`
which might be useless for resource server only project, it
could raise error for missing, unused parameter.
2025-11-21 16:41:25 +01:00
Quentin BEY
2e9ad45f30 (resource-server) fix EC key test
For some reason, this test was false but working. It does not
work anymore with recent version of jose lib so we fix it.
2025-11-21 16:41:25 +01:00
Quentin BEY
3fe817189b ♻️(resource-server) make token introspection earlier
The base implementation from Mozilla let the backend in charge
of making the introspection (probably to stay generic), but
in LaSuite project we will always perform introspection when
acting as resource server.

To improve domain consistency and "payload" access to other part
of the code, we chose to make the introspection earlier in the
authentication process.

Note the introspection payload, does not contain much information,
in our current implementation we need it to contain at least the
user's `sub``.
2025-11-21 16:41:25 +01:00
jbpenrath
8aada72a22 🔖(patch) bump release to 0.0.18
Changed

- 🐛(joserfc) refactor JWT handling with joserfc library updates #35
- 👔(oidc) consider urls as refreshable no matter the HTTP method #42
v0.0.18
2025-11-12 10:00:54 +01:00
jbpenrath
a9e2daa979 👔(oidc) consider urls as refreshable no matter the HTTP method
Currently, only `GET` method as considered as refreshable url as it could
be weird to return a redirect response for other kind of HTTP methods.
On our side, we assume to be always in a XHR context so we don't want
to be bothered by redirects and in case the session has expired
we returned a 401 status. So we can safely ignore the request HTTP method
to check if the url is refreshable.
2025-11-05 10:32:04 +01:00
renovate[bot]
654ec35437 ⬆️(dependencies) update python to 3.14 2025-11-04 15:08:55 +01:00
renovate[bot]
e6a59febd0 ⬆️(dependencies) update actions/setup-python action to v6 2025-11-04 15:08:41 +01:00
renovate[bot]
eed6563c6a ⬆️(dependencies) update actions/checkout action to v5 2025-11-04 15:08:27 +01:00
renovate[bot]
a45bf5801c ⬆️(dependencies) update astral-sh/setup-uv action to v7 2025-11-04 15:08:12 +01:00
renovate[bot]
d9562ee561 ⬆️(dependencies) update dorny/test-reporter action to v2 2025-11-04 15:07:43 +01:00
Quentin BEY
a675805354 💚(renovate) fix configuration to use common config
All our projects inherit from numerique-gouv/renovate-configuration
2025-11-04 15:00:19 +01:00
renovate[bot]
fb32c0fa58 Add renovate.json 2025-11-04 14:18:23 +01:00
Hsiaoming Yang
11a39c5549 ⬆️(joserfc) use jwk.import_key instead of JWKRegistry.import_key
Cleaner code and dependency update
2025-11-04 13:49:35 +01:00
Hsiaoming Yang
f1a357b9b8 (joserfc) remove pyjwt from tests
Use joserfc everywhere.
2025-11-04 13:49:35 +01:00
Hsiaoming Yang
573719be89 🐛(joserfc) refactor JWT handling with library updates
Remove dependency of PyJWT
2025-11-04 13:48:51 +01:00
Manuel Raynaud
a15873e277 🔖(patch) bump release to 0.0.17
Added

- (backend) extract reach and roles choices #33

Fixed

- 🐛(oidc) do not allow user sub update when set #34
v0.0.17
2025-10-27 11:01:05 +01:00
Manuel Raynaud
ef11d21bdb (backend) extract reach and roles choices
We extract the reach and roles choices and all utils function from the
docs project. We will use them in other projects.
2025-10-27 11:01:05 +01:00
Quentin BEY
997329a9b0 🎨(configuration) add missing __init__.py` file
Not a big deal, but better now.
2025-10-24 15:04:30 +02:00
Quentin BEY
61136971e8 🐛(oidc) do not allow user sub update when set
When a user's sub is defined, we don't want to allow any update
because it would break to many related data.

This fix is required since we changed the way user data is
updated in 7409ea8c6e
2025-10-24 15:04:30 +02:00
Quentin BEY
4d53fa6650 🔖(patch) bump release to 0.0.16
Fixed

- 🐛(oidc) fix `update_user` when `User.sub` is nullable #31
v0.0.16
2025-10-24 14:21:00 +02:00
Thomas Recouvreux
7409ea8c6e 🐛(oidc) fix update_user when User.sub is nullable
User model `sub` field may be nullable in certain projects, we make sure
the user is correctly updated in this case by using the User.id during
update.

Example of User.sub being nullable: in case of multi authentication
backends.
Example of project using a nullable User.sub: docs (lasuite).
2025-10-24 14:17:02 +02:00
Ghislain LE MEUR
43f9e74806 🔖(patch) bump release to 0.0.15
Fixed

- 🐛(oidc) validate state param during silent login failure for CSRF protection
- 🐛(oidc) fix session persistence with Redis backend for OIDC flows
v0.0.15
2025-10-24 13:37:42 +02:00
Ghislain LE MEUR
5491204d17 🐛(oidc) fix session persistence with Redis backend for OIDC flows
Fixes session persistence issues with OIDC flows, particularly when
using a Redis backend, and strengthens OIDC security.

Key changes include:

**Session Persistence (Redis)**:
- Forcing immediate session saving (`request.session.modified = True`
  and `request.session.save()`) in OIDC logout and authentication
  views. This is crucial for cache-based session backends like Redis
  to ensure OIDC states are persisted before redirects.
- Simplified session creation by calling `session.create()` BEFORE
  `super().get()` instead of after (more logical flow).
- Removed unnecessary state merging logic that was over-engineering.

**Security Enhancements**:
- Added CSRF protection by validating the state parameter even during
  silent login failures (error=login_required).
- State is now preserved (not deleted) on error=login_required to
  allow the SSO provider to send a subsequent callback with the
  authorization code using the same state.
- Enforced strict state parameter validation during silent login
  failures (`error=login_required`), raising `SuspiciousOperation`
  if state is missing or invalid.
- Graceful handling of logout callbacks without state parameter to
  accommodate SSO providers sending preflight requests.

**Testing**:
- Added comprehensive tests for silent login security validation
  (invalid state, missing state, valid state).
- Updated test expectations to match new behavior where states are
  preserved during silent login failures.
- Added test for logout callback without state parameter.

These changes enhance both the reliability and security of OIDC
login and logout flows, especially in distributed environments
using Redis for session management.
2025-10-24 13:35:54 +02:00
Quentin BEY
b2bbdbd402 (oidc) store IdP session ID in session when provided
Storing this ID allows to kill only a specific session
when calling the backchannel logout endpoint.
2025-10-24 13:27:39 +02:00
Quentin BEY
b5d1027787 (oidc) add backend logout endpoint
This endpoint can be called by the IdP to kill all the user
sessions.

In order to allow to kill only one session, we need to store the
session ID when login from IdP...
2025-10-24 13:27:39 +02:00
Manuel Raynaud
c771bae725 🔖(patch) bump release to 0.0.14
Added

- (drf) implement monitored scope throttling class #27
v0.0.14
2025-09-05 14:32:02 +02:00
Manuel Raynaud
e08b8c7d50 (drf) implement monitored scope throttling class
We want to monitor the usage of a scope throttle. We want to know when a
throttle fails in order to determine if the rate is accurate or not.
To allow custom monitoring, a callback can be use. For example you can
capture a message in sentry instead logging a warning.
2025-09-05 14:32:02 +02:00
Manuel Raynaud
3aaa3dcc02 🔖(patch) bump release to 0.0.13
Fixed

- 🗃️(malware_detection) use dict callable for MalwareDetection
  defaut parameters #26
v0.0.13
2025-08-29 11:12:40 +02:00
Manuel Raynaud
2a98cca09f ♻️(ci) replace git whatchanged by git log
The command git watchanged is deprecated and is flag to be removed soon.
It can be easily replace with git log
2025-08-29 10:20:00 +02:00
Manuel Raynaud
99cfda417c 🗃️(malware_detection) use dict callable for MalwareDetection parameters
The parameters field in the MalwareDetection model does not use a
callable as default value, triggering a fields.E010 warning. We have to
use the `dict` callable instead.
2025-08-29 10:20:00 +02:00