Compare commits
No commits in common. "56846e278104cba08e2f535057252501b2e334d4" and "fdb7acca567c2a720a8526184b6de482b0a737a4" have entirely different histories.
56846e2781
...
fdb7acca56
2 changed files with 5 additions and 22 deletions
|
|
@ -34,7 +34,7 @@ request:
|
||||||
source: access_token
|
source: access_token
|
||||||
settings:
|
settings:
|
||||||
autoFetchToken: true
|
autoFetchToken: true
|
||||||
autoRefreshToken: true
|
autoRefreshToken: false
|
||||||
bundled: false
|
bundled: false
|
||||||
extensions:
|
extensions:
|
||||||
bruno:
|
bruno:
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ internal class Program
|
||||||
Console.Title = "Yavsc.Blogs";
|
Console.Title = "Yavsc.Blogs";
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.AddConfiguration("blogs");
|
builder.AddConfiguration("blogs");
|
||||||
|
|
||||||
var services = builder.Services;
|
var services = builder.Services;
|
||||||
|
|
@ -36,23 +37,10 @@ internal class Program
|
||||||
})
|
})
|
||||||
.AddYavscCors(builder.Configuration)
|
.AddYavscCors(builder.Configuration)
|
||||||
.AddControllers();
|
.AddControllers();
|
||||||
String authority = builder.Configuration.GetValue<string>("Site:Authority");
|
|
||||||
String audience = builder.Configuration.GetValue<string>("Site:Audience");
|
|
||||||
if (string.IsNullOrEmpty(authority))
|
|
||||||
{
|
|
||||||
throw new Exception("Site:Authority is not configured in appsettings.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// AuthenticationBuilder
|
// AuthenticationBuilder
|
||||||
services.AddAuthentication("Bearer")
|
services.AddAuthentication("Bearer")
|
||||||
.AddYavscJwtBearer(builder.Configuration,
|
.AddYavscJwtBearer(builder.Configuration);
|
||||||
options =>
|
|
||||||
{
|
|
||||||
options.Authority = authority;
|
|
||||||
options.Audience = builder.Configuration.GetValue<string>
|
|
||||||
("Site:Audience");
|
|
||||||
});
|
|
||||||
|
|
||||||
// DbContextBuilder
|
// DbContextBuilder
|
||||||
services.AddDbContext<ApplicationDbContext>(options =>
|
services.AddDbContext<ApplicationDbContext>(options =>
|
||||||
|
|
@ -93,20 +81,15 @@ internal class Program
|
||||||
{
|
{
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
|
|
||||||
app
|
app
|
||||||
.UseRouting()
|
.UseRouting()
|
||||||
.UseAuthentication()
|
.UseAuthentication()
|
||||||
.UseAuthorization()
|
.UseAuthorization()
|
||||||
.UseCors("default")
|
.UseCors("default")
|
||||||
;
|
;
|
||||||
app.Services.GetRequiredService<ILoggerFactory>().CreateLogger("Program")
|
|
||||||
.LogInformation($"Yavsc.Blogs started, Authority is '{authority}', Audience is '{audience}'");
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
app.MapIdentityApi<ApplicationUser>().RequireAuthorization("BlogScope")
|
app.MapIdentityApi<ApplicationUser>().RequireAuthorization("BlogScope");
|
||||||
.WithHttpLogging(Microsoft.AspNetCore.HttpLogging.HttpLoggingFields.All)
|
|
||||||
.WithTags("Identity")
|
|
||||||
.WithDescription("Identity API for Yavsc.Blogs")
|
|
||||||
.WithMetadata(new ApiExplorerSettingsAttribute { GroupName = "Identity" });
|
|
||||||
|
|
||||||
app.UseSession();
|
app.UseSession();
|
||||||
await app.RunAsync();
|
await app.RunAsync();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue