Introduce new authentication provider Unauthenticated as the default#3075
Introduce new authentication provider Unauthenticated as the default#3075
Unauthenticated as the default#3075Conversation
Co-authored-by: JerryNixon <1749983+JerryNixon@users.noreply.github.com>
…and JSON schema Co-authored-by: JerryNixon <1749983+JerryNixon@users.noreply.github.com>
Co-authored-by: JerryNixon <1749983+JerryNixon@users.noreply.github.com>
Unauthenticated
There was a problem hiding this comment.
Pull request overview
Introduces a new Unauthenticated authentication provider intended to treat all requests as anonymous without requiring JWT configuration.
Changes:
- Added an
UnauthenticatedASP.NET Core auth handler/scheme and wired it intoStartupauth registration paths. - Updated CLI validation and config validation logic to allow
Unauthenticatedwithout JWT (with warnings for non-anonymous role permissions). - Extended schema and CLI tests/snapshots to include the new provider.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service/Startup.cs | Registers the Unauthenticated auth scheme in both auth configuration paths. |
| src/Core/AuthenticationHelpers/UnauthenticatedAuthenticationHandler/UnauthenticatedAuthenticationHandler.cs | New auth handler that yields an anonymous principal. |
| src/Core/AuthenticationHelpers/UnauthenticatedAuthenticationHandler/UnauthenticatedAuthenticationDefaults.cs | Defines the scheme name constants for the new provider. |
| src/Core/AuthenticationHelpers/UnauthenticatedAuthenticationHandler/UnauthenticatedAuthenticationBuilderExtensions.cs | Adds an AuthenticationBuilder extension to register the new scheme. |
| src/Core/AuthenticationHelpers/SupportedAuthNProviders.cs | Adds Unauthenticated to the supported provider constants. |
| src/Config/ObjectModel/AuthenticationOptions.cs | Adds provider detection helper and updates JWT-required determination logic. |
| src/Cli/Utils.cs | Allows Unauthenticated to omit JWT audience/issuer and updates messaging. |
| src/Cli/ConfigGenerator.cs | Emits a warning when Unauthenticated is used with non-anonymous permissions. |
| src/Cli.Tests/ValidateConfigTests.cs | Adds unit tests for Unauthenticated provider helper methods. |
| src/Cli.Tests/Snapshots/InitTests.EnsureCorrectConfigGenerationWithDifferentAuthenticationProviders_47836da0dfbdc458.verified.txt | Updates snapshot for config generation using Unauthenticated. |
| src/Cli.Tests/InitTests.cs | Adds Unauthenticated as a test case for init/config generation. |
| schemas/dab.draft.schema.json | Adds Unauthenticated to the provider enum and documents it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: Aniruddh25 <3513779+Aniruddh25@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
@copilot, investigate failures in these tests. Fix the tests to accept Unauthenticated provider. https://dev.azure.com/sqldab/fcb212b3-b288-4c9e-b55a-5842a268b16d/_apis/build/builds/18318/logs/45 |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
@copilot, investigate and fix these failures: https://dev.azure.com/sqldab/fcb212b3-b288-4c9e-b55a-5842a268b16d/_apis/build/builds/18329/logs/15 |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
@copilot multiple tests are failing in Unit tests and Integrations tests. for example, this Unit test failed- Stack Trace:
FileContent: NotEqual: Received: UpdateEntityTests.TestUpdateStoredProcedureWithBothMcpPropertiesEnabled.received.txt most of them seems like failing in comparing the expected and generated configs. also, investigate other tests and fix them in this same branch- copilot/add-unauthenticated-auth-provider. |
… helpers Co-authored-by: souvikghosh04 <210500244+souvikghosh04@users.noreply.github.com>
Fixed in 1c13dd5. The root cause was that test helpers and snapshot tests still had
|
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
@copilot the following tests failed in PG integration tests- Put_Insert_WithReadDatabasePolicyUnsatisfiedTest following tests failed for DW SQL integration tests- FindTestsWithFilterQueryStringOneOpFilter following tests failed for MySQL integration tests- please ensure to check for other database tests like MSSQL and Cosmos as well. make sure the functionality is not broken and not deviated from requirements |
…ted breaks role-based policy tests Co-authored-by: souvikghosh04 <210500244+souvikghosh04@users.noreply.github.com>
Fixed in 78e3476. The integration test failures were caused by Reverted all |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
Why make this change?
New authentication provider where all operations run as
anonymous. Useful when DAB is behind an app gateway or APIM where authentication is handled externally.What is this change?
Core Implementation:
UnauthenticatedAuthenticationHandlerinUnauthenticatedAuthentication/folder (follows Simulator pattern)IsUnauthenticatedAuthenticationProvider()toAuthenticationOptions.csIsUnauthenticatedIdentityProviderproperty toRuntimeConfig.csClientRoleHeaderAuthenticationMiddleware.ResolveConfiguredAuthNScheme()AuthenticationOptionsrecord default fromAppServicetoUnauthenticatedIsAppServiceIdentityProviderandIsStaticWebAppsIdentityProviderto only return true when explicitly setCLI & Validation:
dab initdefault fromAppServicetoUnauthenticatedUtils.ValidateAudienceAndIssuerForJwtProvider()accepts Unauthenticated without JWT configConfigGenerator.IsConfigValid()emits warning (not error) when used with non-anonymous rolesSchema:
Unauthenticatedtodab.draft.schema.jsonprovider enumTest Updates:
Unauthenticatedas defaultInitTests.cs,UpdateEntityTests.cs, andTestHelper.csto useUnauthenticatedas the default provider in unit test setup helpersdab-config.*.json) continue to useAppServicebecause integration tests exercise role-based policies (authenticated role, database policies, exclude fields) that require actual token-based authentication — theUnauthenticatedprovider treats all requests as anonymous and does not process bearer tokensKey behaviors:
productionmode (unlike Simulator)authenticated/custom role permissions (warning emitted)How was this tested?
dab-config.*.json) retainAppServiceprovider to support role-based policy testingValidateUnauthenticatedProviderIdentificationinAuthenticationConfigValidatorUnitTests.csTestValidateAudienceAndIssuerForAuthenticationProviderUnauthenticatedas defaultTestUnauthenticatedProviderNonAnonymousRoleDetectionvalidates warning is emitted for non-anonymous rolesSample Request(s)
Config snippet:
{ "runtime": { "host": { "authentication": { "provider": "Unauthenticated" } } } }✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.