Skip to content

Commit

Permalink
Merge pull request #721 from SUNET/ylle-add-msgrelay
Browse files Browse the repository at this point in the history
Add MsgRelay to more apps that need it
  • Loading branch information
johanlundberg authored Dec 6, 2024
2 parents 2f8b5f6 + e646ed3 commit b02789a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/eduid/webapp/bankid/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from eduid.common.config.parsers import load_config
from eduid.common.rpc.am_relay import AmRelay
from eduid.common.rpc.msg_relay import MsgRelay
from eduid.userdb.logs.db import ProofingLog
from eduid.userdb.proofing.db import BankIDProofingUserDB
from eduid.webapp.bankid.settings.common import BankIDConfig
Expand All @@ -28,6 +29,7 @@ def __init__(self, config: BankIDConfig, **kwargs: Any) -> None:

# Init celery
self.am_relay = AmRelay(config)
self.msg_relay = MsgRelay(config)


current_bankid_app: BankIDApp = cast(BankIDApp, current_app)
Expand Down
2 changes: 2 additions & 0 deletions src/eduid/webapp/bankid/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ErrorsConfigMixin,
FrontendActionMixin,
MagicCookieMixin,
MsgConfigMixin,
ProofingConfigMixin,
Pysaml2SPConfigMixin,
)
Expand All @@ -23,6 +24,7 @@ class BankIDConfig(
ProofingConfigMixin,
Pysaml2SPConfigMixin,
FrontendActionMixin,
MsgConfigMixin,
):
"""
Configuration for the eidas app
Expand Down
9 changes: 8 additions & 1 deletion src/eduid/webapp/common/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,14 @@ def get_reference_nin_from_navet_data(nin: str) -> str | None:
"""
Check if the NIN has changed in Navet data.
"""
msg_relay = get_from_current_app("msg_relay", MsgRelay)
try:
msg_relay = get_from_current_app("msg_relay", MsgRelay)
except AttributeError:
# If for some reason the msg_relay is not in the current app, return None.
# This should not happen, but if it does, we don't want to crash the service.
# Instead, we log the error and return None.
logger.error("Could not get msg_relay from current app")
return None

navet_data = msg_relay.get_all_navet_data(nin=nin)
if navet_data.person.reference_national_identity_number:
Expand Down
2 changes: 2 additions & 0 deletions src/eduid/webapp/eidas/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from eduid.common.config.parsers import load_config
from eduid.common.rpc.am_relay import AmRelay
from eduid.common.rpc.msg_relay import MsgRelay
from eduid.userdb.logs.db import ProofingLog
from eduid.userdb.proofing.db import EidasProofingUserDB
from eduid.webapp.common.authn.middleware import AuthnBaseApp
Expand All @@ -28,6 +29,7 @@ def __init__(self, config: EidasConfig, **kwargs: Any) -> None:

# Init celery
self.am_relay = AmRelay(config)
self.msg_relay = MsgRelay(config)


current_eidas_app: EidasApp = cast(EidasApp, current_app)
Expand Down
2 changes: 2 additions & 0 deletions src/eduid/webapp/eidas/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ErrorsConfigMixin,
FrontendActionMixin,
MagicCookieMixin,
MsgConfigMixin,
ProofingConfigMixin,
Pysaml2SPConfigMixin,
)
Expand All @@ -25,6 +26,7 @@ class EidasConfig(
ProofingConfigMixin,
Pysaml2SPConfigMixin,
FrontendActionMixin,
MsgConfigMixin,
):
"""
Configuration for the eidas app
Expand Down
2 changes: 2 additions & 0 deletions src/eduid/webapp/freja_eid/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from eduid.common.config.parsers import load_config
from eduid.common.rpc.am_relay import AmRelay
from eduid.common.rpc.msg_relay import MsgRelay
from eduid.userdb.logs import ProofingLog
from eduid.userdb.proofing.db import FrejaEIDProofingUserDB
from eduid.webapp.common.authn.middleware import AuthnBaseApp
Expand All @@ -25,6 +26,7 @@ def __init__(self, config: FrejaEIDConfig, **kwargs: Any) -> None:
self.proofing_log = ProofingLog(config.mongo_uri)
# Init celery
self.am_relay = AmRelay(config)
self.msg_relay = MsgRelay(config)

# Initialize the oidc_client
self.oidc_client = OAuth(self, cache=SessionOAuthCache())
Expand Down
2 changes: 2 additions & 0 deletions src/eduid/webapp/freja_eid/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ErrorsConfigMixin,
FrontendActionMixin,
MagicCookieMixin,
MsgConfigMixin,
ProofingConfigMixin,
)

Expand Down Expand Up @@ -37,6 +38,7 @@ class FrejaEIDConfig(
ErrorsConfigMixin,
MagicCookieMixin,
FrontendActionMixin,
MsgConfigMixin,
):
"""
Configuration for the svipe_id app
Expand Down

0 comments on commit b02789a

Please sign in to comment.