Skip to content

CDD-3099 update non public caching#3003

Open
kathryn-dale wants to merge 41 commits intomainfrom
task/CDD-3099-update-non-public-caching
Open

CDD-3099 update non public caching#3003
kathryn-dale wants to merge 41 commits intomainfrom
task/CDD-3099-update-non-public-caching

Conversation

@kathryn-dale
Copy link
Copy Markdown
Contributor

@kathryn-dale kathryn-dale commented Feb 17, 2026

Description

This PR includes the following:

  • Add JWT detection middleware to identify if the request comes from a public or non-public user

  • If the request comes from a non-public user, bypass the cache and calculate the data fresh. This newly calculated data should NOT be saved in the cache

  • This work only covers the private api. It has been agreed to leave the public api for now, as private data is not returned from the public api currently, and it has been agreed not to use it for non public data in the immediate future.

Fixes #CDD-3099


Type of change

Please select the options that are relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Tech debt item (this is focused solely on addressing any relevant technical debt)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests at the right levels to prove my change is effective
  • I have added screenshots or screen grabs where appropriate
  • I have added docstrings in the correct style (google)

@kathryn-dale kathryn-dale force-pushed the task/CDD-3099-update-non-public-caching branch from bf3ecb8 to 80a4c29 Compare February 17, 2026 15:08
@kathryn-dale kathryn-dale marked this pull request as ready for review February 18, 2026 10:03
@kathryn-dale kathryn-dale requested a review from a team as a code owner February 18, 2026 10:03
@kathryn-dale kathryn-dale force-pushed the task/CDD-3099-update-non-public-caching branch 3 times, most recently from 44aa955 to 198e1fd Compare March 9, 2026 10:05
@kathryn-dale
Copy link
Copy Markdown
Contributor Author

From a discussion with @mattjreynolds

So the jwt validation (or any Django Authentication middleware) will set the values of request.user (to an instance of the User model) and request.auth (that will contain the valid auth - in this case the decoded jwt). So you should be able to just do simple check along the lines of valid_jwt = request.auth  (request.auth will be set to None for a public (unauthenticated) request). We could decide later on to make that check more specific (once we've figured out exactly how permissions are going to look) at which point we may shift it to calling a function on the permission sets model attached to the user, so something like valid_jwt = request.user.permission_sets.is_valid()  but I think to keep it simple for now, just checking request.auth will be fine, and that will mean your code will just start working as long as it gets merged after mine.

Blocking this work until CDD-3058 is merged and this can be properly tested and completed

@kathryn-dale kathryn-dale force-pushed the task/CDD-3099-update-non-public-caching branch from d7c4e8e to 7b17f60 Compare March 26, 2026 10:32
@kathryn-dale
Copy link
Copy Markdown
Contributor Author

I have reached out to @phill-stanley regarding the sonarqube failures. Namely:

  • There are two versions of the public api which are remarkably similar. This has necessitated duplicate code in the testing, which has crossed the threshold of tolerated levels of duplication

I have also reached out to @mattjreynolds to discuss where the JWT validation should live, to see if it logically can move so it doesn't break the contract

@kathryn-dale kathryn-dale force-pushed the task/CDD-3099-update-non-public-caching branch from c4cab6b to 763be9c Compare March 31, 2026 13:32
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
32.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants