Duende.IdentityServer.Admin
Duende.IdentityServer.Admin copied to clipboard
Fix duplicated healthchecks - #135
- AddDbContextCheck by default checks to see if it can connect to the database
.CanConnectAsync()you can also run a custom query against the context - No longer need healthchecks per db provider
- Name is not required by default it does
nameofon the type now making it refactor friendly
-- 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
@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.
- You probably want to double check the queries, that you are happy with the tables they are querying.
- Check you are happy with me removing the name and moving it to nameof(dbcontext)
- Happy with using tags and the tag names, struggle with identityserver http check
Neat, that does look a lot tidier.
@aiscrim - what do you think? thanks
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?
Thank you for letting me know. I am going to revisit this PR.