Giter VIP home page Giter VIP logo

aspnetcore.identity.cosmosdb's People

Contributors

toiyabe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

rboelen skillgro

aspnetcore.identity.cosmosdb's Issues

NotSupportedException: No IUserTwoFactorTokenProvider<TUser> named 'Default' is registered.

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:

  1. Start with no database or containers created.
  2. Set the secrets so that the Cosmos DB provider can automatically create the database and containers.
  3. Run the website, and try to register a new user.
  4. See error.

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.

Upgrade to .net 8

Having an error that says it cannot find an implementation of Clone() in EntityFramework.Cosmos 7.0.2

How to setup external login providers such as google

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.

Two-factor authentication Bug

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.UserManager1.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>

@toiyabe

MaxAsync does not work on IdentityUserClaim<string> and IdentityRoleClaim<string> records

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".

Screenshots
image
image

Desktop (please complete the following information):

  • TargetFramework net6.0
  • Version="2.1.4"

Additional context
I tried to add claims to a user record and discovered this issue.

Support for .Net 7

.Net 7 is now in “preview” and will be released soon. An implementation is now needed for .Net 7 and 6.

How to update an IdentityUser within CosmosDB?

Discussed in #23

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>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.