fecgov / fecfile-web-app

Other
6 stars 4 forks source link

[SPIKE] Research prevention of mismatched api urls #2414

Open exalate-issue-sync[bot] opened 1 week ago

exalate-issue-sync[bot] commented 1 week ago

Identify potential solutions to avoid committing front end code that requests the api with urls that are correct except for missing a / at the end. These are easy to miss because the api redirects and the app behaves correctly. Consider automated solutions and change of process solutions.

Upon review, follow up tickets will be made for any solutions we decide to act on.

QA Notes

null

DEV Notes

Note: time box to “2” points

Design

null

See full ticket and images here: FECFILE-1843

exalate-issue-sync[bot] commented 21 hours ago

Sasha Dresden commented: So I did some research on this and there are several things I have found out.

It is possible to override this, but we don’t do so very often. Looking at our code base and the /api/docs/ the only place we are doing that is for the oidc calls. I’m not quite sure why we don’t have trailing slashes for them. Perhaps they prefer no trailing slash? Or just whoever set up these routes didn’t add them. But I tried making the mock_oidc calls with a trailing slash and they all work. I did not test with the non-mocked oidc calls, as that would require a push to dev, but I imagine it would behave the same.

The second option is a lot easier and less time consuming to implement and has lower risk now, whereas the first option will require a comprehensive sweep of the front end, so it’ll take a lot longer to implement but we could run into issues in the future if we choose to break the django default of always having a trailing slash.

exalate-issue-sync[bot] commented 20 hours ago

Sasha Dresden commented: Wanted to move this to Code Review but needed something for the PR field so I put the PR I put in for [https://fecgov.atlassian.net/browse/FECFILE-1785|https://fecgov.atlassian.net/browse/FECFILE-1785|smart-link] which implements the front-end interceptor to show how a demo of Option 2. As mentioned in the write-up, Option 1 would require a lot more time investment.