Compare commits
2 commits
fdb7acca56
...
56846e2781
| Author | SHA1 | Date | |
|---|---|---|---|
| 56846e2781 | |||
| 58c08fe2fc |
2 changed files with 22 additions and 5 deletions
|
|
@ -34,7 +34,7 @@ request:
|
||||||
source: access_token
|
source: access_token
|
||||||
settings:
|
settings:
|
||||||
autoFetchToken: true
|
autoFetchToken: true
|
||||||
autoRefreshToken: false
|
autoRefreshToken: true
|
||||||
bundled: false
|
bundled: false
|
||||||
extensions:
|
extensions:
|
||||||
bruno:
|
bruno:
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ 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;
|
||||||
|
|
@ -37,10 +36,23 @@ 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 =>
|
||||||
|
|
@ -81,15 +93,20 @@ 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