Skip to content

Commit

Permalink
feat(idsrv): option to disable health checks
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicGD committed Jul 3, 2024
1 parent d703f1d commit 2f76472
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public abstract class IdentityServerAuthOptions : AuthOptions
{
public string OidcServerUrl { get; set; } = "https://localhost";
public bool RequireHttps { get; set; }
public bool EnableHealthChecks { get; set; } = true;
}

public class IdentityServerAuthOptionsValidator<TOptions> : AuthOptionsValidator<TOptions>
Expand Down
9 changes: 6 additions & 3 deletions src/Sitko.Core.Auth.IdentityServer/IdentityServerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ public override void ConfigureServices(IApplicationContext applicationContext, I
{
base.ConfigureServices(applicationContext, services, startupOptions);
services.TryAddScoped<IUserTokenProvider, UserTokenProvider>();
if (Uri.TryCreate(startupOptions.OidcServerUrl, UriKind.Absolute, out var oidcUri))
if (startupOptions.EnableHealthChecks)
{
if (IdentityServerModuleChecks.Checks.TryAdd(oidcUri.ToString(), true))
if (Uri.TryCreate(startupOptions.OidcServerUrl, UriKind.Absolute, out var oidcUri))
{
services.AddHealthChecks().AddIdentityServer(oidcUri, name: $"IdSrv: {oidcUri}");
if (IdentityServerModuleChecks.Checks.TryAdd(oidcUri.ToString(), true))
{
services.AddHealthChecks().AddIdentityServer(oidcUri, name: $"IdSrv: {oidcUri}");
}
}
}
}
Expand Down

0 comments on commit 2f76472

Please sign in to comment.