2 factors with Identity #787
Unanswered
Thomas-Vil
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi guys,
Thanks for this work, it's indeed huge help for some projects.
I came across some issue with 2 factors, which I could narrow down to simple blazor template with sample data (.net 8.0.1) + Finbuckle.MultiTenant.AspNetCore (6.13.0) + Microsoft.AspNetCore.Identity (8.0.1).
Once the user is authenticated, going to its account details then "Two-factor authentication"
I get
ArgumentException: Entity type 'IdentityUserToken<string>' is defined with a 2-part composite key, but 3 values were passed to the 'Find' method. Microsoft.EntityFrameworkCore.Internal.EntityFinder<TEntity>.ValidateKeyPropertiesAndExtractCancellationToken(object[] keyValues, bool async, CancellationToken cancellationToken) Microsoft.EntityFrameworkCore.Internal.EntityFinder<TEntity>.FindAsync(object[] keyValues, CancellationToken cancellationToken) Microsoft.EntityFrameworkCore.Internal.InternalDbSet<TEntity>.FindAsync(object[] keyValues, CancellationToken cancellationToken) Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserOnlyStore<TUser, TContext, TKey, TUserClaim, TUserLogin, TUserToken>.FindTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken) Microsoft.AspNetCore.Identity.UserStoreBase<TUser, TKey, TUserClaim, TUserLogin, TUserToken>.GetTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken) BlazorApp2000.Components.Account.Pages.Manage.TwoFactorAuthentication.OnInitializedAsync() in TwoFactorAuthentication.razor + private HttpContext HttpContext { get; set; } = default!; protected override async Task OnInitializedAsync() { var user = await UserAccessor.GetRequiredUserAsync(HttpContext); canTrack = HttpContext.Features.Get<ITrackingConsentFeature>()?.CanTrack ?? true; hasAuthenticator = await UserManager.GetAuthenticatorKeyAsync(user) is not null; is2faEnabled = await UserManager.GetTwoFactorEnabledAsync(user); isMachineRemembered = await SignInManager.IsTwoFactorClientRememberedAsync(user); recoveryCodesLeft = await UserManager.CountRecoveryCodesAsync(user); } private async Task OnSubmitForgetBrowserAsync()[...]
I attempted to debug to identify the object passed to the find method but going into it was 99% bouncing me between .net task internals so I didn't make progress in that direction :(
The route strategy has no impact, i.e. all that I've tried exhibit the issue.
There must be a method override I'm missing that doesn't come out of the box, but I'm missing pointers here. Any lead would be appreciated on my end!
Beta Was this translation helpful? Give feedback.
All reactions