Skip to content

Move OAuth2 error messages to Resources.resx for localization#5357

Merged
mikaelweave merged 3 commits intopersonal/mikaelw/fix-415-error-handlingfrom
copilot/sub-pr-5348
Jan 28, 2026
Merged

Move OAuth2 error messages to Resources.resx for localization#5357
mikaelweave merged 3 commits intopersonal/mikaelw/fix-415-error-handlingfrom
copilot/sub-pr-5348

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

Description

Moves hardcoded OAuth2 error messages in TokenIntrospectionController to Resources.resx for proper localization support.

Changes:

  • Added OAuth2ContentTypeMustBeFormUrlEncoded and OAuth2TokenParameterRequired resource strings
  • Updated TokenIntrospectionController to reference resource strings instead of hardcoded values
  • Updated TokenIntrospectionControllerTests to use resource string references in assertions

Related issues

AB#181870

Testing

  • Updated unit tests in TokenIntrospectionControllerTests verify error messages via resource strings
  • All test assertions updated to use Resources.OAuth2ContentTypeMustBeFormUrlEncoded and Resources.OAuth2TokenParameterRequired

FHIR Team Checklist

  • Update the title of the PR to be succinct and less than 65 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
  • Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
  • Tag the PR with Schema Version backward compatible or Schema Version backward incompatible or Schema Version unchanged if this adds or updates Sql script which is/is not backward compatible with the code.
  • When changing or adding behavior, if your code modifies the system design or changes design assumptions, please create and include an ADR.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Patch


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Contributor Author

Copilot AI commented Jan 28, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • microsofthealthoss.pkgs.visualstudio.com
    • Triggering command: /usr/bin/dotnet dotnet build src/Microsoft.Health.Fhir.Api/Microsoft.Health.Fhir.Api.csproj --no-restore (dns block)
    • Triggering command: /usr/bin/dotnet dotnet restore src/Microsoft.Health.Fhir.Api/Microsoft.Health.Fhir.Api.csproj (dns block)
    • Triggering command: /usr/bin/dotnet dotnet test src/Microsoft.Health.Fhir.Api.UnitTests/Microsoft.Health.Fhir.R4.Api.UnitTests.csproj --filter FullyQualifiedName~TokenIntrospectionControllerTests --no-restore --no-build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Add RFC-compliant error handling for TokenIntrospectionController Move OAuth2 error messages to Resources.resx for localization Jan 28, 2026
Copilot AI requested a review from mikaelweave January 28, 2026 19:53
@mikaelweave mikaelweave marked this pull request as ready for review January 28, 2026 19:57
@mikaelweave mikaelweave requested a review from a team as a code owner January 28, 2026 19:57
@mikaelweave mikaelweave merged commit 9953f52 into personal/mikaelw/fix-415-error-handling Jan 28, 2026
3 checks passed
@mikaelweave mikaelweave deleted the copilot/sub-pr-5348 branch January 28, 2026 19:57
mikaelweave added a commit that referenced this pull request Jan 28, 2026
)

* Add support for UnsupportedMediaType error handling in FhirController

* Add support for UnsupportedMediaType error handling in FhirController

* Implement OAuth2 error handling and token introspection validation

- Added OAuth2BadRequestException for handling bad request errors.
- Introduced OAuth2ExceptionFilterAttribute to return RFC 6749 compliant error responses.
- Updated TokenIntrospectionController to validate content type and token presence.
- Enhanced TokenIntrospectionControllerTests to cover new validation scenarios.
- Added documentation for token introspection examples.

* Refactor authorization checks in TokenIntrospectionController to allow any data action for token introspection

* Fix for local authority issues

* Refactor authentication and authorization handling in DevelopmentIdentityProviderRegistrationExtensions and FhirServerServiceCollectionExtensions

* Add authorization middleware to FhirServerApplicationBuilderExtensions and remove redundant authorization call from FhirServerServiceCollectionExtensions

* Implement conditional authorization middleware for development identity provider

* Remove redundant [Authorize] attribute from TokenIntrospectionController

* Add script to generate runsettings for E2E tests and update .gitignore

* Update Token Introspection examples and remove redundant authorization test

* Remove unsupported media type handling and related resources

* Fix security alert: Remove user input from log entry

* Add sample requests for RFC 7662 Token Introspection endpoint

* Move OAuth2 error messages to Resources.resx for localization (#5357)

* Initial plan

* Move error messages to Resources.resx for localization

Co-authored-by: mikaelweave <[email protected]>

* Add periods to error messages for consistency

Co-authored-by: mikaelweave <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: mikaelweave <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: mikaelweave <[email protected]>
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