feat(RPS): MS authorizer service & Postcode Lookup Service - #607
marco-ukhsa wants to merge 6 commits into
Conversation
b2331f6 to
5ace378
Compare
|
Hi @marco-ukhsa, the code is looking good On initial review I have the below observations Code Todo[] Address Type missing (currently 'unknown') QuestionsMulti tenant support[] Does the current implementation give multi tenant support (given a single deployed server instance is hosting multiple forms which may need their own MSAL configuration) [] With this being an inheritance based design, is the multi tenant support facilitated through a per form IOC registration of the addressLookupService? Default values[] Do default values make sense from a technical standpoint or only suitable to RPS usage Token[] Lifecycle / TTL - Looks like per address lookup, is this per-call approach future proof (thinking other future services and calls requiring MSAL, like secure form submissions?) Missing documentationSome possible ideas below that would be helpful (can be placed in docs/runner?) Use cases[] DI registration Configuration[] MSAL variables (are they form level?) Multi tenant support[] How it's facilitated Token[] Lifetime / Lifecycle / TTL |
Hi @Dashue, thank you for the fast review! Code Todo
Multi-tenant support
Default values
Token
Missing documentation
|
|
Hi @marco-ukhsa, that's perfect! I think your notes on Default values and Token are really insightful and worth including in the documentation as well? |
please let me know if there's anything else that can I can add to improve this service |
|
Hi @marco-ukhsa thanks for the updates Hope the below makes sense, let me know if I've misunderstood anything DI registration to support multi tenancy I believe the approach would need to register a named instance per form that depend on the location service const forms: FormConfiguration[] = configureEnginePlugin(
formFileName,
formFilePath,
options
);
const locationServiceInstances = [];
for (const form of forms) {
if (form.configuration.locationService.apimBaseUrl) {
// form.id comes from idFromFilename in runner\src\server\plugins\engine\helpers.ts
// id = filename.replace(/govsite\.|\.json|/gi, "");
const addressLookupInstanceName = `locationServiceInstance:${form.id}`;
locationServiceInstances.push(
Schmervice.withName(addressLookupInstanceName, AddressLookupService)
);
// Or instead of gathering a list just do multiple registrations in the this iteration:
// await server.registerService(Schmervice.withName(addressLookupInstanceName, AddressLookupService));
}
}
if (locationServiceInstances.length) {
await server.registerService(locationServiceInstances);
}Extend @xgovformbuilder/model with new form level configuration Separate doc for MsalAuthorizer I'm working on the APIM support for secure file uploads and I think we can take a similar to AddressLookupService and re-use the MsalAuthorizerService. Which at that point the secure form submission documentation could then similarly just reference the MsalAuthorizer/MsalAuthorizerService documentation |
Address lookup service & msal authorizer service
Introduces two new services for address lookup via APIM and shared MSAL authentication.
Changes
msalAuthorizerService.tstenantId,clientId,clientSecret, andscopesfrom callergetToken()method which returns the Bearer token stringaddressLookupService.tslookupByPostcode()against the agency's APIM/matchAddressendpointmaxResults, fuzzy, and dataset options or leaving as defaultmsalAuthorizerServicefor fetching and using Bearer tokenOcp-Apim-Subscription-Keyheader only if the subscription key is provided from callerNotes
AddressLookupConfigextendsMsalAuthorizerConfigso the auth config is passed through a single object