Add Web UI for the SMS Site
This commit is contained in:
47
TwilioSMSReceiver.Web/Program.cs
Normal file
47
TwilioSMSReceiver.Web/Program.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.Authorization;
|
||||
using Microsoft.Identity.Web;
|
||||
using Microsoft.Identity.Web.UI;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var initialScopes = builder.Configuration["DownstreamApi:Scopes"]?.Split(' ') ?? builder.Configuration["MicrosoftGraph:Scopes"]?.Split(' ');
|
||||
// Add services to the container.
|
||||
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
|
||||
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))
|
||||
.EnableTokenAcquisitionToCallDownstreamApi(initialScopes)
|
||||
.AddMicrosoftGraph(builder.Configuration.GetSection("MicrosoftGraph"))
|
||||
.AddInMemoryTokenCaches();
|
||||
|
||||
builder.Services.AddAuthorization(options =>
|
||||
{
|
||||
// By default, all incoming requests will be authorized according to the default policy.
|
||||
options.FallbackPolicy = options.DefaultPolicy;
|
||||
});
|
||||
builder.Services.AddRazorPages()
|
||||
.AddMicrosoftIdentityUI();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
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.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapRazorPages();
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user