Skip to content

Commit 1ef2471

Browse files
committed
Output console : MiniAuth management is listening on {address}/miniauth/index.html
1 parent 3a7f918 commit 1ef2471

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/MiniAuth.IdentityAuth/MiniAuthIdentityBuilderExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Hosting.Server.Features;
23
using Microsoft.AspNetCore.Identity;
34
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
45
using Microsoft.EntityFrameworkCore;
56
using Microsoft.Extensions.DependencyInjection;
67
using Microsoft.Extensions.FileProviders;
8+
using Microsoft.Extensions.Logging;
79
using MiniAuth;
810
using System;
911
using System.Data;
@@ -26,9 +28,7 @@ public static IApplicationBuilder UseMiniAuth<TDbContext, TIdentityUser, TIdenti
2628
where TIdentityRole : IdentityRole, new()
2729
{
2830
_ = builder ?? throw new ArgumentNullException(nameof(builder));
29-
#if DEBUG
3031
builder.UseMiddleware<MiniAuthIdentityMiddleware>();
31-
#endif
3232

3333
if (!builder.Properties.TryGetValue("__UseRouting", out var _))
3434
builder.UseRouting();
Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
using Microsoft.AspNetCore.Hosting.Server;
2-
using Microsoft.AspNetCore.Hosting.Server.Features;
1+
using Microsoft.AspNetCore.Hosting.Server.Features;
2+
using Microsoft.AspNetCore.Hosting.Server;
33
using Microsoft.AspNetCore.Http;
44
using Microsoft.Extensions.DependencyInjection;
55
using Microsoft.Extensions.Logging;
66
using System.Diagnostics;
77

8-
#if DEBUG
8+
99
public partial class MiniAuthIdentityMiddleware
1010
{
1111
private readonly RequestDelegate _next;
1212
private readonly ILogger<MiniAuthIdentityMiddleware> _logger;
13+
private static bool FirstRun = true;
1314
public MiniAuthIdentityMiddleware(RequestDelegate next,
1415
ILogger<MiniAuthIdentityMiddleware> logger
1516
)
@@ -19,10 +20,19 @@ ILogger<MiniAuthIdentityMiddleware> logger
1920
}
2021
public async Task Invoke(HttpContext context)
2122
{
23+
if (FirstRun)
24+
{
25+
FirstRun = false;
26+
var server = context.RequestServices.GetService<IServer>();
27+
var addressFeature = server.Features.Get<IServerAddressesFeature>();
28+
foreach (var address in addressFeature.Addresses)
29+
{
30+
_logger.LogInformation($"MiniAuth management is listening on address: {address}/miniauth/index.html");
31+
}
32+
}
2233
Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}, Path: {context.Request.Path}");
23-
2434
await _next(context);
2535
}
2636
}
27-
#endif
37+
2838

0 commit comments

Comments
 (0)