File: Program.cs
Web Access
Project: src\src\Security\Authentication\OpenIdConnect\samples\MinimalOpenIdConnectSample\MinimalOpenIdConnectSample.csproj (MinimalOpenIdConnectSample)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Security.Claims;
 
var builder = WebApplication.CreateBuilder(args);
 
builder.Services
    .AddAuthentication("OpenIdConnect")
    .AddCookie()
    .AddOpenIdConnect();
builder.Services.AddAuthorization();
 
var app = builder.Build();
 
app.MapGet("/protected", (ClaimsPrincipal user) => $"Hello {user.Identity?.Name}!")
    .RequireAuthorization();
 
app.Run();