diff --git a/oidc-controller/api/core/oidc/tests/__mocks__.py b/oidc-controller/api/core/oidc/tests/__mocks__.py index 0d87a4be..3057c8e0 100644 --- a/oidc-controller/api/core/oidc/tests/__mocks__.py +++ b/oidc-controller/api/core/oidc/tests/__mocks__.py @@ -1,6 +1,10 @@ from datetime import datetime, timedelta -from api.verificationConfigs.models import VerificationConfig, VerificationProofRequest +from api.verificationConfigs.models import ( + VerificationConfig, + VerificationProofRequest, + MetaData, +) from api.authSessions.models import AuthSession # Presentation returned from the debug webhook @@ -1342,13 +1346,13 @@ ver_config_id="verified-email", subject_identifier="email", metadata={ - "title": {"en": "Get Name"}, - "claims": { - "en": [ + "en": MetaData( + title="Get Name", + claims=[ "That you are a BC Resident", "That you are a member of the Law Society of British Columbia", - ] - }, + ], + ), }, proof_request=VerificationProofRequest( name="BCGov Verified Email", diff --git a/oidc-controller/api/routers/oidc.py b/oidc-controller/api/routers/oidc.py index 2e4f6828..165cf78a 100644 --- a/oidc-controller/api/routers/oidc.py +++ b/oidc-controller/api/routers/oidc.py @@ -35,6 +35,7 @@ from ..verificationConfigs.crud import VerificationConfigCRUD from ..verificationConfigs.helpers import VariableSubstitutionError +from ..verificationConfigs.models import MetaData ChallengePollUri = "/poll" @@ -202,6 +203,11 @@ async def get_authorize(request: Request, db: Database = Depends(get_db)): # BC Wallet deep link wallet_deep_link = gen_deep_link(auth_session) + metadata = ( + ver_config.metadata["en"] + if ver_config.metadata and "en" in ver_config.metadata + else MetaData(title="Scan with a Digital Wallet", claims=[]) + ) # This is the payload to send to the template data = { "image_contents": image_contents, @@ -212,20 +218,8 @@ async def get_authorize(request: Request, db: Database = Depends(get_db)): "controller_host": controller_host, "challenge_poll_uri": ChallengePollUri, "wallet_deep_link": wallet_deep_link, - "title": ( - ver_config.metadata.title.get("en") - if ver_config.metadata - and ver_config.metadata.title - and ver_config.metadata.title.get("en") - else "Scan with a Digital Wallet" - ), - "claims": ( - ver_config.metadata.claims.get("en") - if ver_config.metadata - and ver_config.metadata.claims - and ver_config.metadata.claims.get("en") - else [] - ), + "title": metadata.title, + "claims": metadata.claims, } # Prepare the template diff --git a/oidc-controller/api/verificationConfigs/models.py b/oidc-controller/api/verificationConfigs/models.py index a2b796a1..0af8450a 100644 --- a/oidc-controller/api/verificationConfigs/models.py +++ b/oidc-controller/api/verificationConfigs/models.py @@ -39,8 +39,8 @@ class VerificationProofRequest(BaseModel): class MetaData(BaseModel): - title: dict[str, str] | None = Field(default=None) - claims: dict[str, list[str]] | None = Field(default=None) + title: str | None = Field(default=None) + claims: list[str] | None = Field(default=None) class VerificationConfigBase(BaseModel): @@ -48,7 +48,7 @@ class VerificationConfigBase(BaseModel): proof_request: VerificationProofRequest = Field() generate_consistent_identifier: bool | None = Field(default=False) include_v1_attributes: bool | None = Field(default=False) - metadata: MetaData | None = Field(default=None) + metadata: dict[str, MetaData] | None = Field(default=None) def get_now(self) -> int: return int(time.time())