Apply the existing feature filter so EnableAadSmartOnFhirProxy - #5865
Merged
Richa Bansal (rbans96) merged 6 commits intoSep 22, 2026
Merged
Conversation
…proxy controller AadSmartOnFhirProxyFeatureFilterAttribute already exists and correctly returns 401 when Security:EnableAadSmartOnFhirProxy is false, but it was never applied to any controller, so it has no effect. As a result the /AadSmartOnFhirProxy endpoints (authorize, callback, token) stay fully functional even when the feature is turned off. The flag currently only changes what /metadata and /.well-known/smart-configuration advertise; it does not disable the feature itself. This applies the existing filter to AadSmartOnFhirProxyController so the configuration setting actually controls the endpoints. The filter is ordered after the audit logging filter so that calls made while the feature is disabled are still audited before being rejected. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The filter had no test coverage. These cover both its behaviour and, importantly, the fact that it is actually applied to the controller -- the latter being what was missing and what allowed the setting to be silently ignored. - Disabled feature returns UnauthorizedResult. - Enabled feature does not short-circuit the request. - The filter is present in AadSmartOnFhirProxyController's attributes. - Audit logging is ordered ahead of it, so calls made while the feature is disabled are still recorded before being rejected. Verified that the two wiring tests fail when the attribute is removed from the controller, while the two behaviour tests continue to pass. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 task
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5865 +/- ##
==========================================
+ Coverage 78.71% 78.83% +0.12%
==========================================
Files 1018 1018
Lines 37126 37127 +1
Branches 5680 5679 -1
==========================================
+ Hits 29222 29268 +46
+ Misses 6498 6459 -39
+ Partials 1406 1400 -6 🚀 New features to boost your workflow:
|
Copilot started reviewing on behalf of
Mikael Weaver (mikaelweave)
September 21, 2026 22:16
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The controller performs OpenID discovery before action filters execute, so disabled requests may fail with a 5xx instead of returning 401.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Applies the existing SMART-on-FHIR proxy feature filter to the proxy controller and adds unit coverage.
Changes:
- Adds the feature filter to
AadSmartOnFhirProxyController. - Adds behavior and attribute-order tests.
- Includes the new test in the shared test project.
| File | Description |
|---|---|
AadSmartOnFhirProxyController.cs |
Applies feature gating to proxy endpoints. |
AadSmartOnFhirProxyFeatureFilterAttributeTests.cs |
Tests filter behavior and registration. |
Microsoft.Health.Fhir.Shared.Api.UnitTests.projitems |
Compiles the new tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Keep the MVC action filters responsible for auditing and returning 401 without requiring authority configuration or outbound discovery. Cover disabled routes, enabled actions and error handling through TestServer. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Cover enabled authorization-code exchange and launch context propagation, and verify disabled invalid requests are audited as 401 before action validation. No production behavior changes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Give the test handler ownership of discovery and token responses and release them during cleanup. Verify content stays readable until the client disposes the handler. Addresses both CodeQL review comments without changing production behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Move repeated discovery client and factory wiring into CreateHost. Let the host own the client while each test retains ownership of its handler and responses. Addresses the image-only review suggestion without production changes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Mikael Weaver (mikaelweave)
approved these changes
Sep 22, 2026
Richa Bansal (rbans96)
enabled auto-merge (squash)
September 22, 2026 18:57
Richa Bansal (rbans96)
deleted the
fix/gate-smart-proxy-endpoints-on-feature-flag
branch
September 22, 2026 19:24
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
AadSmartOnFhirProxyFeatureFilterAttributealready exists and does the right thing — it returns401whenSecurity:EnableAadSmartOnFhirProxyisfalse. However, it is never applied to any controller, so it has no effect today.The consequence is that
EnableAadSmartOnFhirProxydoes not actually control the feature. It only changes what the discovery documents advertise:Related issues
Address https://microsofthealth.visualstudio.com/Health/_workitems/edit/197109
Testing
Unit tests are added
FHIR Team Checklist
Semver Change (docs)
Patch|Skip|Feature|Breaking (reason)