-
Notifications
You must be signed in to change notification settings - Fork 332
Introduce new authentication provider Unauthenticated as the default
#3075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
souvikghosh04
merged 33 commits into
main
from
copilot/add-unauthenticated-auth-provider
Mar 12, 2026
Merged
Changes from 4 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
4618b06
Initial plan
Copilot e4c09d2
Updated plan with new requirements
Copilot f63c338
Add Unauthenticated authentication provider with CLI support, tests, …
Copilot 1a2f633
Fix typo in UnauthenticatedAuthenticationBuilderExtensions comment
Copilot b6d0fd5
Update src/Cli/Utils.cs
JerryNixon a441af8
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
JerryNixon e3fb034
Address PR review comments: add Unauthenticated scheme mapping, use e…
Copilot 00444b8
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
RubenCerna2079 f0b25d0
Address PR review comments: rename folder, update docs, simplify warn…
Copilot ac245d6
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
Aniruddh25 0330922
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
JerryNixon 17844ce
Change default authentication provider from AppService to Unauthentic…
Copilot 8b364ca
Remove unused using directive from ValidateConfigTests.cs
Copilot 015659f
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
Aniruddh25 0d0b3f8
Use IsJwtConfiguredIdentityProvider() in Startup.cs for cleaner code
Copilot 86dfde1
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
Aniruddh25 a62d2fa
Fix: Revert AuthenticationOptions record default to AppService for ba…
Copilot 9c68fb7
Change default authentication provider to Unauthenticated and update …
Copilot 58e0328
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
Aniruddh25 b0add00
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
RubenCerna2079 5dfac7d
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
Aniruddh25 afbe0be
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
Aniruddh25 a8781ac
Update snapshot files to use Unauthenticated as default provider
Copilot bb114bf
Add --auth.provider AppService to config generator command files for …
Copilot d9b2ec5
Revert config-generator commands and update test configs to use Unaut…
Copilot 684a9c6
Update Service.Tests snapshots to use Unauthenticated provider
Copilot 62588b4
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
JerryNixon 1c13dd5
Fix snapshot tests to use Unauthenticated as default provider in test…
Copilot 78e3476
Revert integration test config files to use AppService - Unauthentica…
Copilot 98dcb85
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
souvikghosh04 bd6fe6b
Fixing failing tests
souvikghosh04 630832a
Fix failing unit test for Unauthenticated with no audience
souvikghosh04 4d4f4b1
Merge branch 'main' into copilot/add-unauthenticated-auth-provider
souvikghosh04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
50 changes: 50 additions & 0 deletions
50
...CorrectConfigGenerationWithDifferentAuthenticationProviders_47836da0dfbdc458.verified.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| { | ||
| DataSource: { | ||
| DatabaseType: MSSQL, | ||
| Options: { | ||
| set-session-context: false | ||
| } | ||
| }, | ||
| Runtime: { | ||
| Rest: { | ||
| Enabled: true, | ||
| Path: /api, | ||
| RequestBodyStrict: true | ||
| }, | ||
| GraphQL: { | ||
| Enabled: true, | ||
| Path: /graphql, | ||
| AllowIntrospection: true | ||
| }, | ||
| Mcp: { | ||
| Enabled: true, | ||
| Path: /mcp, | ||
| DmlTools: { | ||
| AllToolsEnabled: true, | ||
| DescribeEntities: true, | ||
| CreateRecord: true, | ||
| ReadRecords: true, | ||
| UpdateRecord: true, | ||
| DeleteRecord: true, | ||
| ExecuteEntity: true, | ||
| UserProvidedAllTools: false, | ||
| UserProvidedDescribeEntities: false, | ||
| UserProvidedCreateRecord: false, | ||
| UserProvidedReadRecords: false, | ||
| UserProvidedUpdateRecord: false, | ||
| UserProvidedDeleteRecord: false, | ||
| UserProvidedExecuteEntity: false | ||
| } | ||
| }, | ||
| Host: { | ||
| Cors: { | ||
| AllowCredentials: false | ||
| }, | ||
| Authentication: { | ||
| Provider: Unauthenticated | ||
| }, | ||
| Mode: Production | ||
| } | ||
| }, | ||
| Entities: [] | ||
| } |
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
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
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
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
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
34 changes: 34 additions & 0 deletions
34
...rs/UnauthenticatedAuthenticationHandler/UnauthenticatedAuthenticationBuilderExtensions.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Microsoft.AspNetCore.Authentication; | ||
|
|
||
| namespace Azure.DataApiBuilder.Core.AuthenticationHelpers.UnauthenticatedAuthenticationHandler; | ||
|
|
||
| /// <summary> | ||
| /// Extension methods related to Unauthenticated authentication. | ||
| /// This class allows setting up Unauthenticated authentication in the startup class with | ||
| /// a single call to .AddAuthentication(scheme).AddUnauthenticatedAuthentication() | ||
| /// </summary> | ||
| public static class UnauthenticatedAuthenticationBuilderExtensions | ||
| { | ||
| /// <summary> | ||
| /// Add authentication with Unauthenticated provider. | ||
| /// </summary> | ||
| /// <param name="builder">Authentication builder.</param> | ||
| /// <returns>The builder, to chain commands.</returns> | ||
| public static AuthenticationBuilder AddUnauthenticatedAuthentication(this AuthenticationBuilder builder) | ||
| { | ||
| if (builder is null) | ||
| { | ||
| throw new System.ArgumentNullException(nameof(builder)); | ||
| } | ||
|
|
||
| builder.AddScheme<AuthenticationSchemeOptions, UnauthenticatedAuthenticationHandler>( | ||
| authenticationScheme: UnauthenticatedAuthenticationDefaults.AUTHENTICATIONSCHEME, | ||
| displayName: UnauthenticatedAuthenticationDefaults.AUTHENTICATIONSCHEME, | ||
| configureOptions: null); | ||
|
|
||
| return builder; | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
...tionHelpers/UnauthenticatedAuthenticationHandler/UnauthenticatedAuthenticationDefaults.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| namespace Azure.DataApiBuilder.Core.AuthenticationHelpers.UnauthenticatedAuthenticationHandler; | ||
|
|
||
| /// <summary> | ||
| /// Default values related to UnauthenticatedAuthentication handler. | ||
| /// </summary> | ||
| public static class UnauthenticatedAuthenticationDefaults | ||
| { | ||
| /// <summary> | ||
| /// The default value used for UnauthenticatedAuthenticationOptions.AuthenticationScheme. | ||
| /// </summary> | ||
| public const string AUTHENTICATIONSCHEME = "UnauthenticatedAuthentication"; | ||
| } |
49 changes: 49 additions & 0 deletions
49
...ationHelpers/UnauthenticatedAuthenticationHandler/UnauthenticatedAuthenticationHandler.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Security.Claims; | ||
| using System.Text.Encodings.Web; | ||
| using Microsoft.AspNetCore.Authentication; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Extensions.Options; | ||
|
|
||
| namespace Azure.DataApiBuilder.Core.AuthenticationHelpers.UnauthenticatedAuthenticationHandler; | ||
|
JerryNixon marked this conversation as resolved.
Outdated
|
||
|
|
||
| /// <summary> | ||
| /// This class is used to best integrate with ASP.NET Core AuthenticationHandler base class. | ||
| /// When "Unauthenticated" is configured, this handler authenticates the user as anonymous, | ||
| /// without reading any HTTP authentication headers. | ||
| /// </summary> | ||
| public class UnauthenticatedAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions> | ||
| { | ||
| /// <summary> | ||
| /// Constructor for the UnauthenticatedAuthenticationHandler. | ||
| /// Note the parameters are required by the base class. | ||
| /// </summary> | ||
| /// <param name="options">Authentication options.</param> | ||
| /// <param name="logger">Logger factory.</param> | ||
| /// <param name="encoder">URL encoder.</param> | ||
| public UnauthenticatedAuthenticationHandler( | ||
| IOptionsMonitor<AuthenticationSchemeOptions> options, | ||
| ILoggerFactory logger, | ||
| UrlEncoder encoder) | ||
| : base(options, logger, encoder) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns an unauthenticated ClaimsPrincipal for all requests. | ||
| /// The ClaimsPrincipal has no identity and no claims, representing an anonymous user. | ||
| /// </summary> | ||
| /// <returns>An authentication result to ASP.NET Core library authentication mechanisms</returns> | ||
| protected override Task<AuthenticateResult> HandleAuthenticateAsync() | ||
| { | ||
| // ClaimsIdentity without authenticationType means the user is not authenticated (anonymous) | ||
| ClaimsIdentity identity = new(); | ||
| ClaimsPrincipal claimsPrincipal = new(identity); | ||
|
|
||
| AuthenticationTicket ticket = new(claimsPrincipal, UnauthenticatedAuthenticationDefaults.AUTHENTICATIONSCHEME); | ||
| AuthenticateResult success = AuthenticateResult.Success(ticket); | ||
| return Task.FromResult(success); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.