Improve integration with Aspire #4

Closed
opened 2026-02-21 18:18:15 +00:00 by Grandiras · 0 comments
Owner

builder.Services.AddAtProtoAuthentication(options =>
{
options.ClientName = "Digital Independence Dashboard";
options.LoginPath = "/login";
// AT Proto loopback clients require http:// — derive the HTTP URL from ASPNETCORE_URLS
var urls = builder.Configuration["ASPNETCORE_URLS"] ?? "";
var httpUrl = urls.Split(';').FirstOrDefault(u => u.TrimStart().StartsWith("http://", StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrEmpty(httpUrl)) options.BaseUrl = httpUrl.Replace("://localhost", "://127.0.0.1", StringComparison.OrdinalIgnoreCase);
options.ClaimsFactory = result =>
[
new Claim(ClaimTypes.NameIdentifier, result.Did),
new Claim(ClaimTypes.Name, result.Handle),
new Claim(ClaimTypes.Role, result.Handle == "grandiras.net" ? "Admin" : "User"),
];
});

builder.Services.AddAtProtoAuthentication(options => { options.ClientName = "Digital Independence Dashboard"; options.LoginPath = "/login"; // AT Proto loopback clients require http:// — derive the HTTP URL from ASPNETCORE_URLS var urls = builder.Configuration["ASPNETCORE_URLS"] ?? ""; var httpUrl = urls.Split(';').FirstOrDefault(u => u.TrimStart().StartsWith("http://", StringComparison.OrdinalIgnoreCase)); if (!string.IsNullOrEmpty(httpUrl)) options.BaseUrl = httpUrl.Replace("://localhost", "://127.0.0.1", StringComparison.OrdinalIgnoreCase); options.ClaimsFactory = result => [ new Claim(ClaimTypes.NameIdentifier, result.Did), new Claim(ClaimTypes.Name, result.Handle), new Claim(ClaimTypes.Role, result.Handle == "grandiras.net" ? "Admin" : "User"), ]; });
Sign in to join this conversation.
No description provided.