⬆️(joserfc) use jwk.import_key instead of JWKRegistry.import_key

Cleaner code and dependency update
This commit is contained in:
Hsiaoming Yang
2025-11-04 14:08:36 +09:00
committed by Quentin BEY
parent f1a357b9b8
commit 11a39c5549
3 changed files with 8 additions and 6 deletions

View File

@@ -8,6 +8,10 @@ and this project adheres to
## [Unreleased]
### Changed
- 🐛(joserfc) refactor JWT handling with joserfc library updates #35
## [0.0.17] - 2025-10-27
### Added

View File

@@ -30,7 +30,7 @@ dependencies = [
"django>=5.0",
"djangorestframework>=3.15.2",
"mozilla-django-oidc>=4.0.1",
"joserfc>=1.0.4",
"joserfc>=1.4.0",
"requests>=2.32.3",
"requests-toolbelt>=1.0.0",
]

View File

@@ -2,7 +2,7 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from joserfc.jwk import JWKRegistry
from joserfc import jwk
def import_private_key_from_settings():
@@ -32,11 +32,9 @@ def import_private_key_from_settings():
if not private_key_str:
raise ImproperlyConfigured("OIDC_RS_PRIVATE_KEY_STR setting is missing or empty.")
private_key_pem = private_key_str.encode()
try:
private_key = JWKRegistry.import_key(
private_key_pem,
private_key = jwk.import_key(
private_key_str,
key_type=settings.OIDC_RS_ENCRYPTION_KEY_TYPE,
parameters={"alg": settings.OIDC_RS_ENCRYPTION_ALGO, "use": "enc"},
)