Decode managed identity token for dicom API routes#1355
Merged
Conversation
MatMoore
reviewed
Apr 20, 2026
MatMoore
reviewed
Apr 20, 2026
MatMoore
reviewed
Apr 20, 2026
5475223 to
7c46fbb
Compare
| """ | ||
| The expected issuer claim(s) in the JWT token. This should match the tenant ID and the Azure AD endpoints. | ||
| """ | ||
| return [ |
Contributor
There was a problem hiding this comment.
maybe worth constantising these?
AZURE_AD_V1_ISSUER_TEMPLATE = "https://sts.windows.net/{tenant_id}/"
AZURE_AD_V2_ISSUER_TEMPLATE = "https://login.microsoftonline.com/{tenant_id}/v2.0/"
or some such
Contributor
Author
There was a problem hiding this comment.
This didn't work without converting tenant id to a constant too. something to do with the templating.
I've cached the string/array properties which use tenant id to prevent unnecessary interpolation, this has the benefit of docstrings in the body of the property definition.
Refactor authentication to use PyJWKClient with caching options. Move decode options into properties.
a682f89 to
a2c81a5
Compare
The JWKSClient caches the keys from the given discovery keys endpoint, so this property should also be cached on the Authentication instance. Cache a couple of other properties we only need to create once per instance.
a2c81a5 to
5c12134
Compare
|
carlosmartinez
approved these changes
Apr 29, 2026
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.



Description
We will authenticate dicom API requests using a token generated by a system assigned managed identity.
See NHSDigital/manage-breast-screening-gateway#96 for how we will do this.
This PR adds AD based token authentication for all dicom routes.
Jira link
https://nhsd-jira.digital.nhs.uk/browse/DTOSS-12807
and part of
https://nhsd-jira.digital.nhs.uk/browse/DTOSS-12648
Review notes
Not covered in this PR: How we authorise the incoming request (spoilers: using the
oidauth claim)Review checklist
/api/v1/), confirm whether it is a breaking change — if so, a new major version (/api/v2/) is required (see ADR-006)