120 Commits

Author SHA1 Message Date
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
Manuel Raynaud
4620dda522 🔖(patch) bump release to 0.0.12
Added

- (malware_detection) limit simultaneous files analysis for jcop #25

Fixed

- 🐛(tests) fix test_project app to be usable with management command #25
v0.0.12
2025-07-22 17:03:54 +02:00
Manuel Raynaud
501e94d0fc (malware_detection) management command launching pending analysis
We added a management command to force to launch pending analysis. This
management command can be run periodically in a cron in order to have a
pending analysis blocked and never run.
2025-07-22 17:03:54 +02:00
Manuel Raynaud
1169eda8eb (malware_detection) limit simultaneous files analysis for jcop
For the JCOP backend we need to limit the number of simultaneous files
analysis. The number of simultaneous analysis must be configurable, by
default we limit it to 15.
To achieve this, we store in a table the pending analysis and a new
analysis is triggered at the end of a previous one.
2025-07-22 17:03:54 +02:00
Manuel Raynaud
5ba2dea9c7 🐛(tests) fix test_project app to be usable with management command
The test_project app had missing configuration blocking usage of the
django admin management commands. We need to use them for generating
migrations.
2025-07-22 17:03:54 +02:00
Quentin BEY
200bdc106e 🔖(patch) bump release to 0.0.11
Fixed

- 🐛(resource-server) allow `aud` & `iss` JWE headers #24
v0.0.11
2025-07-09 14:44:41 +02:00
Quentin BEY
dbd4e8f25c 🚨(joserfc) fix deprecation warning
RSAKey must be imported from `joserfc.jwk`.
2025-07-09 14:39:31 +02:00
Quentin BEY
53f1adaf67 🐛(resource-server) allow aud & iss JWE headers
The new implementation in Proconnect uses the panva
node-oidc-provider lib which add two extra headers.
We allow them but not rely on them.
2025-07-09 14:39:25 +02:00
Quentin BEY
4455ebe41a 🔖(patch) bump release to 0.0.10
Fixed

- 🐛(oidc-rs) fix non base 64 authentication token #21
- 📝(pyproject) fix the package metadata #23
v0.0.10
2025-06-18 13:30:54 +02:00
Manuel Raynaud
c5ba9134b2 📝(doc) add missing OIDC_OP_INTROSPECTION_ENDPOINT usage
In the how to use oidc resource server backend documentation, tu usage
of the OIDC_OP_INTROSPECTION_ENDPOINT settings was missing.
2025-06-18 11:41:22 +02:00
Quentin BEY
93e918713e 📝(pyproject) fix the package metadata
Fix the list of supported Python & Django versions
2025-06-06 17:48:08 +02:00
Quentin BEY
b7569faddd (tox) add test matrix for Python/Django versions
This add the tox configuration and update the CI to run tests across all
supported versions.
2025-06-06 17:48:08 +02:00
Quentin BEY
04c184fc0d 💩(tests) monkeypatch the InMemoryFileNode
Django < 5.2 does not properly store the name.
2025-06-06 17:40:58 +02:00
Quentin BEY
69b7c34ada (jose) fix test after new version of jose lib
Fix after release of joserfc v1.1.0
2025-06-06 17:32:36 +02:00
Quentin BEY
ed7d009c05 🔥(uv) remove lock file
We don't want to lock file as this is a library.
2025-06-06 17:31:21 +02:00
Quentin BEY
b5383fbc53 🐛(oidc-rs) fix non base 64 authentication token
When the token is a JWT, the base64 testing was failing when calling the
resource server endpoint.
2025-05-20 18:41:56 +02:00
Manuel Raynaud
516d1eb5cd 🔖(patch) bump release to 0.0.9
Added

- (configuration) add configuration Value to support file path
  in environment #15

Changed

- ♻️(malware_detection) retry getting analyse result sooner
v0.0.9
2025-05-20 16:00:26 +02:00
soyouzpanda
06dc5aa836 (configuration) add configuration Value to support file path in env
This supports use of environment variables that either reference
a value or a path to file containing the value. This is useful for
secrets, to avoid the secret to be in a world-readable environment
file.
2025-05-20 15:51:24 +02:00
Manuel Raynaud
88816d1de9 ♻️(malware_detection) retry getting analyse result sooner
Once an analyse started, we were wiating 30 seconds to try having a
first time the result and then the retry delay was always equal to 30
seconds between every retries. JCOP ask us to reduce this waiting time
to few seconds, an analyse job should start quickly and depending the
file size the result will be available in few seconds.
2025-05-20 15:38:59 +02:00
Manuel Raynaud
5f09ce6d72 📝(malware_detection) update documentation
The usage of a Fernet key and its related settings was still in the documentation. This commit removes it.
2025-05-07 08:52:36 +02:00
Manuel Raynaud
3b661c2fb2 🔖(patch) bump release to 0.0.8
Added

(malware_detection) add a module malware_detection #11

Fixed

- 🐛(oidc) fix resource server client when using JSON introspection #16
- 🔊(oidc) improve resource server log for inactive user #17
- 🐛(oidc) use the OIDC_USER_SUB_FIELD when needed #18
- 🩹(oidc) remove deprecated cgi use #19
v0.0.8
2025-05-06 18:37:29 +02:00
Manuel Raynaud
f7dc1baac6 🔧(gitignore) ignore uv.lock file
As this project is a library, we don't want ot use an exact dependencies
version.
2025-05-06 18:35:37 +02:00
Manuel Raynaud
453018a732 (malware_detection) add a module malware_detection
In many projects we need a solution to analyse file to detect malware in
them. We want to do this job once here and then reuse it in all the
projects.
2025-05-06 18:35:37 +02:00
Quentin BEY
b166ec9de4 🩹(oidc) remove deprecated cgi use
The `cgi` module is deprecated, so use Django to parse the content type
header.
2025-05-05 14:33:36 +02:00
Quentin BEY
f9e9e60e12 🐛(oidc) use the OIDC_USER_SUB_FIELD when needed
The code allows to not use `sub` to store the sub data of the user, but
some part of the code, where still using the hardcoded `sub` attribute.
2025-05-05 14:28:02 +02:00
Quentin BEY
2f4dfa08bf 🔊(oidc) improve resource server log inactive user
The claims validation was making an error when the user is inactive
making debug session quite complex. This does not change the behavior
but add more explicit logs.
2025-05-05 12:39:17 +02:00
Quentin BEY
653b4f7ae7 🐛(oidc) fix resource server client
The client was always requesting for a JWT introspection reponse even if
we wanted a JSON. This commit fixes the issue by hard linking the
resource server client to the resource server backend we use.
2025-05-05 09:46:06 +02:00
Quentin BEY
582861b7c7 🔖(patch) bump release to 0.0.7
Fixed:

- 🐛(oidc) fix user info endpoint format auto #12
v0.0.7
2025-04-23 10:20:09 +02:00
Quentin BEY
21714305d4 🐛(oidc) fix user info endpoint format auto
The content type may contain more information than just the content
type, like the charset.
2025-04-23 10:16:03 +02:00
Quentin BEY
9785af1f96 🔖(patch) bump release to 0.0.6
This contains breaking changes but this is still the very beginning of
the library.

Changed:

- 💥(oidc) normalize setting names #10
v0.0.6
2025-04-11 14:11:05 +02:00
Quentin BEY
477d532291 🎨(tests) use the pytest fixture for dj settings
Make the use of the pytest fixture uniform across our code.
2025-04-11 14:04:37 +02:00