3fc7bf2b97
Build backend images / build content-svc (push) Failing after 3m39s
Build backend images / build file-svc (push) Failing after 52s
Build backend images / build gateway (push) Failing after 58s
Build backend images / build identity-svc (push) Failing after 1m21s
Build backend images / build notification-svc (push) Failing after 1m0s
Build backend images / build render-svc (push) Failing after 58s
Build backend images / build studio-svc (push) Failing after 55s
AI SEO content generator - content-svc: per-tenant OpenAI config (ai_settings) + /v1/ai endpoints (settings GET/PUT, seo-post) with SEO-expert prompt → structured article - admin UI to configure token/base-url/model and generate + save as blog - configurable base URL for restricted networks Full data-driven admin panel - generic /api/admin/resource proxy + reusable AdminResource component - categories/tags/fonts/blogs (CRUD), users (list + ban), plans/slides - AI content section; nav + i18n i18n localization sweep - localized 116 user-facing + studio/editor components to next-intl (fa+en) under the auto.* namespace; merge tooling in scripts/merge-i18n.js Branding + assets - Monoline F logo (LogoMark + favicon) - offline SVG placeholder generator (/api/placeholder), dropped picsum.photos Fixes - JWT issuer mismatch on content/studio (flatrender → flatrender-identity) - missing role claim → [Authorize(Roles="Admin")] now works (RBAC) - Secure cookies broke HTTP sessions → gated behind AUTH_COOKIE_SECURE - Radix RTL via DirectionProvider (right-aligned menus in fa) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
121 lines
5.4 KiB
C#
121 lines
5.4 KiB
C#
using System.Text;
|
|
using FlatRender.StudioSvc.Application.Services;
|
|
using FlatRender.StudioSvc.Domain.Enums;
|
|
using FlatRender.StudioSvc.Infrastructure.Data;
|
|
using FlatRender.StudioSvc.Middleware;
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using Microsoft.OpenApi.Models;
|
|
using Npgsql;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// ── Database ─────────────────────────────────────────────────────────────────
|
|
// Native PostgreSQL enums are mapped on the EF provider so Npgsql can read/write them
|
|
// at runtime (HasPostgresEnum in the model alone is not enough on Npgsql 8+).
|
|
builder.Services.AddDbContext<StudioDbContext>(opt =>
|
|
opt.UseNpgsql(
|
|
builder.Configuration.GetConnectionString("Default"),
|
|
npgsql => npgsql.MapEnum<SavedProjectType>("saved_project_type", "studio", PreserveCaseNameTranslator.Instance))
|
|
.UseSnakeCaseNamingConvention());
|
|
|
|
// ── Application services ──────────────────────────────────────────────────────
|
|
builder.Services.AddScoped<StudioService>();
|
|
|
|
// ── Auth ──────────────────────────────────────────────────────────────────────
|
|
var jwtKey = builder.Configuration["Jwt:Key"]
|
|
?? throw new InvalidOperationException("Jwt:Key is required");
|
|
|
|
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
.AddJwtBearer(opt =>
|
|
{
|
|
opt.TokenValidationParameters = new TokenValidationParameters
|
|
{
|
|
ValidateIssuerSigningKey = true,
|
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtKey)),
|
|
ValidateIssuer = true,
|
|
ValidIssuer = builder.Configuration["Jwt:Issuer"],
|
|
ValidateAudience = true,
|
|
ValidAudience = builder.Configuration["Jwt:Audience"],
|
|
ValidateLifetime = true,
|
|
ClockSkew = TimeSpan.FromSeconds(30),
|
|
};
|
|
});
|
|
|
|
builder.Services.AddAuthorization();
|
|
|
|
// ── Controllers ───────────────────────────────────────────────────────────────
|
|
builder.Services.AddRouting(opts =>
|
|
{
|
|
opts.LowercaseUrls = true;
|
|
opts.AppendTrailingSlash = false;
|
|
});
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
// ── Swagger ───────────────────────────────────────────────────────────────────
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen(c =>
|
|
{
|
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "FlatRender Studio Service", Version = "v1" });
|
|
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
|
{
|
|
Name = "Authorization",
|
|
Type = SecuritySchemeType.Http,
|
|
Scheme = "bearer",
|
|
BearerFormat = "JWT",
|
|
In = ParameterLocation.Header
|
|
});
|
|
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
|
{
|
|
{
|
|
new OpenApiSecurityScheme
|
|
{
|
|
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" }
|
|
},
|
|
[]
|
|
}
|
|
});
|
|
});
|
|
|
|
// ── CORS ──────────────────────────────────────────────────────────────────────
|
|
builder.Services.AddCors(opt =>
|
|
opt.AddDefaultPolicy(p => p
|
|
.WithOrigins(
|
|
builder.Configuration.GetSection("Cors:Origins").Get<string[]>()
|
|
?? ["http://localhost:3000"])
|
|
.AllowAnyHeader()
|
|
.AllowAnyMethod()));
|
|
|
|
// ── Health check ──────────────────────────────────────────────────────────────
|
|
builder.Services.AddHealthChecks();
|
|
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
var app = builder.Build();
|
|
|
|
// ── Auto-migrate in Development ───────────────────────────────────────────────
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
using var scope = app.Services.CreateScope();
|
|
await scope.ServiceProvider.GetRequiredService<StudioDbContext>()
|
|
.Database.MigrateAsync();
|
|
}
|
|
|
|
// ── Middleware pipeline ───────────────────────────────────────────────────────
|
|
app.UseMiddleware<ExceptionMiddleware>();
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Studio v1"));
|
|
}
|
|
|
|
app.UseCors();
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
app.MapControllers();
|
|
app.MapHealthChecks("/health");
|
|
|
|
app.Run();
|