skoruba / Duende.IdentityServer.Admin

The administration for the Duende IdentityServer and Asp.Net Core Identity ⚡
Apache License 2.0
549 stars 194 forks source link

Fix duplicated healthchecks - #135 #137

Open holytshirt opened 1 year ago

holytshirt commented 1 year ago
-- IdentityServerConfigurationDbContext  context.Clients.AnyAsync(token)
SELECT CASE
    WHEN EXISTS (
        SELECT 1
        FROM [Clients] AS [c]) THEN CAST(1 AS bit)
    ELSE CAST(0 AS bit)
END
-- IdentityServerPersistedGrantDbContext context.Keys.AnyAsync(token)
SELECT CASE
    WHEN EXISTS (
        SELECT 1
        FROM [Keys] AS [k]) THEN CAST(1 AS bit)
    ELSE CAST(0 AS bit)
END
-- AdminIdentityDbContext context.Set<TUser>().AnyAsync(token)
SELECT CASE
    WHEN EXISTS (
        SELECT 1
        FROM [Users] AS [u]) THEN CAST(1 AS bit)
    ELSE CAST(0 AS bit)
END
-- AdminLogDbContext context.Logs.AnyAsync(token)
SELECT CASE
    WHEN EXISTS (
        SELECT 1
        FROM [Log] AS [l]) THEN CAST(1 AS bit)
    ELSE CAST(0 AS bit)
END
-- AdminAuditLogDbContext context.AuditLog.AnyAsync(token)
SELECT CASE
    WHEN EXISTS (
        SELECT 1
        FROM [AuditLog] AS [a]) THEN CAST(1 AS bit)
    ELSE CAST(0 AS bit)
END
-- IdentityServerDataProtectionDbContext context.DataProtectionKeys.AnyAsync(token)
SELECT CASE
    WHEN EXISTS (
        SELECT 1
        FROM [DataProtectionKeys] AS [d]) THEN CAST(1 AS bit)
    ELSE CAST(0 AS bit)
END
holytshirt commented 1 year ago

@skoruba
Using a query also means if there is no data in a table the healthcheck fails. Personally I would not have the queries and just make sure you can connect.

  1. You probably want to double check the queries, that you are happy with the tables they are querying.
  2. Check you are happy with me removing the name and moving it to nameof(dbcontext)
  3. Happy with using tags and the tag names, struggle with identityserver http check
colin-freemarketfx commented 1 year ago

Neat, that does look a lot tidier.

skoruba commented 1 year ago

@aiscrim - what do you think? thanks

reydelleon-skuvault commented 1 month ago

Did this ever come to anything? I have the same issue that this PR attempted to address. A few releases have been put out since this Pr was created but these changes were never included. Can the PR at least be closed to signify we should give up on it?

skoruba commented 1 month ago

Thank you for letting me know. I am going to revisit this PR.