Skip to content
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

No app.UseAuthentication() in webapp with individual identity #29388

Closed
propounder opened this issue May 30, 2023 · 2 comments
Closed

No app.UseAuthentication() in webapp with individual identity #29388

propounder opened this issue May 30, 2023 · 2 comments
Assignees
Labels
doc-idea seQUESTered Identifies that an issue has been imported into Quest. Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

@propounder
Copy link

propounder commented May 30, 2023

Here is the generated code by visual studio:
Even though the app does not have app.UseAuthentication(), it has no problem.

using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using WebAppTest.Data;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
builder.Services.AddDbContext<ApplicationDbContext>(options =>
    options.UseSqlServer(connectionString));
builder.Services.AddDatabaseDeveloperPageExceptionFilter();

builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
    .AddEntityFrameworkStores<ApplicationDbContext>();
builder.Services.AddRazorPages();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseMigrationsEndPoint();
}
else
{
    app.UseExceptionHandler("/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.MapRazorPages();

app.Run();


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.


Associated WorkItem - 96054

@dotnet-bot dotnet-bot added ⌚ Not Triaged Source - Docs.ms Docs Customer feedback via GitHub Issue labels May 30, 2023
@Rick-Anderson
Copy link
Contributor

Rick-Anderson commented May 30, 2023

Thanks for reporting this. Code needs to be updated for ASP.NET Core 6 and later.
In ASP.NET Core 6.0 and later, the authentication middleware is automatically enabled by default without explicitly calling UseAuthentication.

@Rick-Anderson Rick-Anderson self-assigned this May 30, 2023
@Rick-Anderson Rick-Anderson added the reQUEST Triggers an issue to be imported into Quest label May 30, 2023
@github-actions github-actions bot added seQUESTered Identifies that an issue has been imported into Quest. and removed reQUEST Triggers an issue to be imported into Quest labels May 31, 2023
@Rick-Anderson Rick-Anderson moved this to To do in Next sprint Oct 18, 2023
@Rick-Anderson
Copy link
Contributor

Dup of #27219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-idea seQUESTered Identifies that an issue has been imported into Quest. Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

No branches or pull requests

3 participants