moonrisesoftwarecalifornia / aspnetcore.identity.cosmosdb Goto Github PK
View Code? Open in Web Editor NEWAsp.Net Identity framework using Cosmos DB
License: MIT License
Asp.Net Identity framework using Cosmos DB
License: MIT License
When trying to implement a query using the UserManager.User property, it returns an “unable to cast” error.
Describe the bug
When registering a new user, the following error occurs:
System.NotSupportedException: No IUserTwoFactorTokenProvider<TUser> named 'Default' is registered. at Microsoft.AspNetCore.Identity.UserManager 1.GenerateUserTokenAsync(TUser user, String tokenProvider, String purpose) at Microsoft.AspNetCore.Identity.UserManager 1.GenerateEmailConfirmationTokenAsync(TUser user) at AspNetCore.Identity.CosmosDb.Example.Areas.Identity.Pages.Account.RegisterModel.OnPostAsync(String returnUrl) in C:\Users\eric\source\repos\CosmosSoftware\AspNetCore.Identity.CosmosDb\AspNetCore.Identity.CosmosDb.Example\Areas\Identity\Pages\Account\Register.cshtml.cs:line 119 at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Convert[T](Object taskAsObject) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
User account is created and a confirmation token is emailed to the new users
Additional context
It looks like the provider injection needs to add the default IUserTwoFactorTokenProvider.
Having an error that says it cannot find an implementation of Clone() in EntityFramework.Cosmos 7.0.2
Please can you suggest how to setup external login providers such as google, facebook etc. with this setup using default packages such as Microsoft.AspNetCore.Authentication.Google. As per the Microsoft documentation the configuration needs to be as below
services.AddAuthentication().AddGoogle(googleOptions =>
{
googleOptions.ClientId = configuration["Authentication:Google:ClientId"];
googleOptions.ClientSecret = configuration["Authentication:Google:ClientSecret"];
});
But the AddAuthentication in package AspNetCore.Identity.CosmosDb
the extension method AddAuthentication is inside the package.
Hi
I got an error on the Two-factor authentication.
after registering the user when you go to the profile page and click on Two-factor authentication you get this error :
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.NotSupportedException: Store does not implement IUserAuthenticatorKeyStore.
at Microsoft.AspNetCore.Identity.UserManager1.GetAuthenticatorKeyStore() at Microsoft.AspNetCore.Identity.UserManager
1.GetAuthenticatorKeyAsync(TUser user)
at CosmosDB_Test.Areas.Identity.Pages.Account.Manage.TwoFactorAuthenticationModel.OnGetAsync() in C:\Users\Sam\source\repos\CosmosDB_Test\CosmosDB_Test\Areas\Identity\Pages\Account\Manage\TwoFactorAuthentication.cshtml.cs:line 68
==========================================================
I use these packages:
<ItemGroup>
<PackageReference Include="AspNetCore.Identity.CosmosDb" Version="2.0.18" />
<PackageReference Include="AspNetCore.Identity.Services.SendGrid" Version="2.0.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Cosmos" Version="6.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.10" />
</ItemGroup>
Describe the bug
MaxAsync does not work on IdentityUserClaim and IdentityRoleClaim records.
To Reproduce
Steps to reproduce the behavior:
Following code produces SQL like
SELECT MAX(c["Id"]) AS m FROM root c WHERE(c["Discriminator"] = "IdentityUserClaim<string>")
'Id' field is stored as string value, therefore the MAX operation does not work as expected.
Example data set: "Id": "9", "Id": "10"
Current behavior max result is "9" instead of "10".
Expected behavior
Current behavior max result has to be "10" instead of "9".
Desktop (please complete the following information):
Additional context
I tried to add claims to a user record and discovered this issue.
.Net 7 is now in “preview” and will be released soon. An implementation is now needed for .Net 7 and 6.
Originally posted by etriebe February 2, 2024
I'm trying to update objects within CosmosDB just like I've done with other objects but I get an exception when I do so. I'm only updating username but I get this error.
Microsoft.Azure.Cosmos.CosmosException
HResult=0x80131500
Message=Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 2aaf5d6d-4433-4488-8f52-905849797594; Reason: (Message: {"Errors":["One of the specified inputs is invalid"]}
ActivityId: 2aaf5d6d-4433-4488-8f52-905849797594, Request URI: /apps/8ce365e5-ba15-438a-a471-07d6b564394d/services/22cbecbc-8764-4e5b-b75b-76fa9b95216b/partitions/fd5ad3bd-b31c-455f-868a-f9c2ca0c97c2/replicas/133265169497594395p/, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.22631 cosmos-netstandard-sdk/3.31.4);
Source=Microsoft.Azure.Cosmos.Client
StackTrace:
at Microsoft.Azure.Documents.StoreResult.ToResponse(RequestChargeTracker requestChargeTracker)
at Microsoft.Azure.Documents.ConsistencyWriter.WritePrivateAsync(DocumentServiceRequest request, TimeoutHelper timeout, Boolean forceRefresh)
at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync[TParam,TPolicy](Func`1 callbackMethod, Func`3 callbackMethodWithParam, Func`2 callbackMethodWithPolicy, TParam param, IRetryPolicy retryPolicy, IRetryPolicy`1 retryPolicyWithArg, Func`1 inBackoffAlternateCallbackMethod, Func`2 inBackoffAlternateCallbackMethodWithPolicy, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)
at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)
at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync[TParam,TPolicy](Func`1 callbackMethod, Func`3 callbackMethodWithParam, Func`2 callbackMethodWithPolicy, TParam param, IRetryPolicy retryPolicy, IRetryPolicy`1 retryPolicyWithArg, Func`1 inBackoffAlternateCallbackMethod, Func`2 inBackoffAlternateCallbackMethodWithPolicy, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)
at Microsoft.Azure.Documents.ConsistencyWriter.WriteAsync(DocumentServiceRequest entity, TimeoutHelper timeout, Boolean forceRefresh, CancellationToken cancellationToken)
at Microsoft.Azure.Documents.ReplicatedResourceClient.<>c__DisplayClass31_0.<<InvokeAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Azure.Documents.RequestRetryUtility.ProcessRequestAsync[TRequest,IRetriableResponse](Func`1 executeAsync, Func`1 prepareRequest, IRequestRetryPolicy`2 policy, CancellationToken cancellationToken, Func`1 inBackoffAlternateCallbackMethod, Nullable`1 minBackoffForInBackoffCallback)
at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)
at Microsoft.Azure.Documents.RequestRetryUtility.ProcessRequestAsync[TRequest,IRetriableResponse](Func`1 executeAsync, Func`1 prepareRequest, IRequestRetryPolicy`2 policy, CancellationToken cancellationToken, Func`1 inBackoffAlternateCallbackMethod, Nullable`1 minBackoffForInBackoffCallback)
at Microsoft.Azure.Documents.StoreClient.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken, IRetryPolicy retryPolicy)
at Microsoft.Azure.Cosmos.Handlers.TransportHandler.ProcessMessageAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.Handlers.TransportHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
This exception was originally thrown at this call stack:
[External Code]
Pickem.Shared.Utilities.Data.IdentityDBUtils.UpdateUserAsync(Microsoft.AspNetCore.Identity.IdentityUser) in IdentityDBUtils.cs
```</div>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.