ADO-2787 basic auth configured in api call#89
Merged
Conversation
Collaborator
Author
|
@bzimonjaSDPR would you like me to include basic auth for additional functions in this request like the expireTokenInPortal and getParametersFromPortal? Or should this auth be tested first and then added to the others? |
Collaborator
Author
|
@bzimonjaSDPR also-also, the error handling from this will just change the page to |
…to ADO-2787-add-authenication-portal-config-file
DavidOkulski
approved these changes
Sep 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes did you make?
getSavedFormFromPortal has two potential POST calls it will make depending on the following conditions:
Additionally, added values to APP_CONFIG in my .env, so those do not appear here in this change. If I need to add them to .env.example, please let me know.
Why did you make these changes?
As per https://dev.azure.com/BC-SDPR/Forms%20Modernization/_workitems/edit/2787/, basic authentication needs to be enabled in order to make calls to FF. If the auth is not in place, the call will error and Edit Form for portal values will not be allowed.
What alternatives did you consider?
I considered using several if-else statements in order to separate the environment variables triggering auth required in POST call. If I did this, then I would not need to write out code for base64 conversion of basicAuth username & password environment variables. Axois has an auth part that does basic auth. HOWEVER, if there's ever a chance a different authentication process is needed, then a new conditional statement would be required (like how basicAuth vs. apiSecret would then require an if/else-if for each). Because of everything included in the POST request, this greatly increases the lines of code and makes it harder to track updates for all API calls in the code.
I went with one if-statement for all the auth, and then one else-statement for no auth because this reduces the coding required if there's any changes. It also allows all auth checks to be in one place, and if non-basic auth types are required then it can be configured to include them in the if-statement.
Future Concerns
While testing this call from Kiln -> Comm Layer -> Local Server, there were two things of note:
In Kiln, the call that activates this endpoint is in EditPortalFormPage. It is supposed to take in the body of params, however in doing so it was not passing along the
idfrom the url. Instead, I had to change the body being passed along from what it is below to:body: JSON.stringify({"id": params[""]}),const body: Record<string, any> = { ...params };
const response = await fetch(loadDataEndpoint, {
method: "POST",
headers,
body: JSON.stringify(body),
});
If this edit portal functionality does not work once in dev/tst/prod, then we may need to look into this as the potential issue.
Leaving this for reference if someone else is trying to connect Comm Layer to a local server that's not in docker. I had to set my apiHost to 0.0.0.0 and had to proxy the host in POST + turn off VPN before it would work.
Checklist