0

I am supporting a site that uses identityserver for authentication and I am trying to understand how it works. Periodically the site becomes bit slow and from appinsights I can see the endpoint which calls RoleManager.FindByNameAsync(name) randomly becomes slow.

Appinsights shows that FindByNameAsync will call our sql db:

SELECT [t].[Id], [t].[Email], [t].[FirstName], [t].[LastName], [t].[UserName], [t].[CreatedAtUtc] AS [CreatedAt], [t].[EmailConfirmed], [t].[LastLoginUtc] AS [LastLogin], [t].[LockoutEnabled], [t].[LockoutEnd] AS [LockoutEndDateUtc], [claim].[ClaimType] AS [Type], [claim].[ClaimValue] AS [Value], [claim].[Id] AS [Id0]
FROM [UserClaims] AS [claim]
INNER JOIN (
    SELECT [user].*
    FROM [Users] AS [user]
    WHERE [user].[Id] IN (
        SELECT [claim0].[UserId]
        FROM [UserClaims] AS [claim0]
        WHERE ([claim0].[ClaimType] = @__type_0) AND ([claim0].[ClaimValue] = @__value_1)
    )
) AS [t] ON [claim].[UserId] = [t].[Id]

The db call itself is not slow (100ms at max), so I am guessing the c# code is doing something.

How RoleManager.FindByNameAsync is integrated with identityserver? RoleManager is a Microsoft extension and I didn't really find a setting in our config which links identityserver to this (admit that I am quite new with identityserver).

daxu
  • 3,514
  • 5
  • 38
  • 76
  • I don't think identityserver has anything to do with it. I believe this is purely an asp.net identity issue. – Aviad P. Sep 12 '22 at 05:13
  • but how above method knows how query data from identityserver tables? – – daxu Sep 12 '22 at 08:24
  • Where do you see any identityserver tables involved? – Aviad P. Sep 12 '22 at 08:46
  • in my appinsight log – daxu Sep 12 '22 at 09:04
  • Can you please include that in the question? – Aviad P. Sep 12 '22 at 09:10
  • sorry, include what? – daxu Sep 12 '22 at 11:06
  • Hmm, the parts from your appinsights that indicate access to identityserver tables, as opposed to asp.net identity tables... Unless I'm reading this wrong the tables shown in your question above are not identityserver tables (UserClaims, etc...) – Aviad P. Sep 12 '22 at 11:25
  • Is it? I believe they are identityserver (v4) tables, otherwise we paid high price to some contractor and he did very shitty job then – daxu Sep 12 '22 at 17:11
  • Look in your code for the code that renames asp.net identity tables, check out this question for example on what to search for https://stackoverflow.com/questions/19460386/how-can-i-change-the-table-names-when-using-asp-net-identity – Aviad P. Sep 12 '22 at 17:41
  • Did you ever get this resolved? – Aviad P. Sep 16 '22 at 06:18
  • sorry, no. We got a new contractor migrating this to the latest identityserver now. Guess wait and see if I still see this kind of query in appinsight – daxu Sep 16 '22 at 09:18
  • I think you should be asking your contractor the hard questions, and having them come here to follow up :) – Aviad P. Sep 16 '22 at 09:26
  • really good point – daxu Sep 16 '22 at 09:28

0 Answers0