aws / aws-sdk-net-extensions-cognito

An extension library to assist in the Amazon Cognito User Pools authentication process
Apache License 2.0
102 stars 49 forks source link

Added support for generic CognitoUser in CognitoUserPool #104

Closed petrenslavik closed 1 year ago

petrenslavik commented 1 year ago

Description of changes: The issue is related to the https://github.com/aws/aws-aspnet-cognito-identity-provider package when used with a custom ApplicationUser class inherited from CognitoUser. The problem is that CognitoUserStore in methods FindByEmailAsync and FindByIdAsync use CognitoUserPool to get the user and then tries to upcast this instance which obviously leads to the user being null.

Adding virtual modifiers will allow changing the implementation of CognitoUserPool methods to return custom own instances.

I understand that I can create a new inherited from CognitoUserStore implementation of the store to override these 2 methods with a custom CognitoUserPool, but this PR will reduce this boilerplate code. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

petrenslavik commented 1 year ago

I also think it will be better to make Provider and ClientSecret properties to be protected instead of private to be able to use them in the inherited class instead of creating new fields.

normj commented 1 year ago

This PR was released as part of version 2.3.0