Skip to content

Commit

Permalink
🐛 [#4713] Fix token exchange for BRP client
Browse files Browse the repository at this point in the history
previously the submission was not passed, causing token exchange to not work
  • Loading branch information
stevenbal committed Oct 8, 2024
1 parent 5c1147b commit e346543
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 7 additions & 0 deletions src/openforms/contrib/haal_centraal/clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ def get_brp_client(submission: Submission | None = None, **kwargs: Any) -> BRPCl
f"No suitable client class configured for API version {version}"
)

if submission:
kwargs.setdefault("context", {})
# pass submission to ensure token exchange works properly
# only do this if the submission is not None, to avoid unnecessary database queries
# done by token_exchange.auth.TokenAccessAuth
kwargs["context"]["submission"] = submission

return build_client(
service,
client_factory=ClientCls,
Expand Down
11 changes: 2 additions & 9 deletions src/openforms/prefill/contrib/haalcentraal_brp/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from openforms.contrib.haal_centraal.constants import BRPVersions
from openforms.contrib.haal_centraal.models import HaalCentraalConfig
from openforms.plugins.exceptions import InvalidPluginConfiguration
from openforms.pre_requests.clients import PreRequestClientContext
from openforms.submissions.models import Submission

from ...base import BasePlugin
Expand Down Expand Up @@ -111,10 +110,7 @@ def get_prefill_values(
identifier_role: IdentifierRoles = IdentifierRoles.main,
) -> dict[str, Any]:
try:
client = get_brp_client(
submission=submission,
context=PreRequestClientContext(submission=submission),
)
client = get_brp_client(submission=submission)
except NoServiceConfigured:
return {}

Expand All @@ -141,10 +137,7 @@ def get_co_sign_values(
the value is the prefill value to use for that attribute.
"""
try:
client = get_brp_client(
submission=submission,
context=PreRequestClientContext(submission=submission),
)
client = get_brp_client(submission=submission)
except NoServiceConfigured:
return ({}, "")

Expand Down

0 comments on commit e346543

Please sign in to comment.