Skip to content

Commit

Permalink
Console miniauth backend url #176
Browse files Browse the repository at this point in the history
  • Loading branch information
shps951023 committed Jun 23, 2024
1 parent 13a081a commit 85285ee
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/MiniAuth.IdentityAuth/MiniAuthIdentityMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand All @@ -17,6 +20,7 @@ public partial class MiniAuthIdentityMiddleware
private readonly ILogger<MiniAuthIdentityMiddleware> _logger;
private readonly MiniAuthOptions _options;
private readonly StaticFileMiddleware _staticFileMiddleware;
private static bool FirstRun = true;
public MiniAuthIdentityMiddleware(RequestDelegate next,
ILogger<MiniAuthIdentityMiddleware> logger,
ILoggerFactory loggerFactory,
Expand All @@ -34,6 +38,16 @@ public MiniAuthIdentityMiddleware(RequestDelegate next,
}
public async Task Invoke(HttpContext context)
{
if (FirstRun)
{
FirstRun = false;
var server = context.RequestServices.GetService<IServer>();
var addressFeature = server.Features.Get<IServerAddressesFeature>();
foreach (var address in addressFeature.Addresses)
{
_logger.LogInformation($"MiniAuth management is listening on address: {address}/miniauth/index.html");
}
}
#if DEBUG
Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}, Path: {context.Request.Path}");
#endif
Expand Down

0 comments on commit 85285ee

Please sign in to comment.