![]() |
VOOZH | about |
dotnet add package Amazon.AspNetCore.Identity.Cognito --version 4.0.2
NuGet\Install-Package Amazon.AspNetCore.Identity.Cognito -Version 4.0.2
<PackageReference Include="Amazon.AspNetCore.Identity.Cognito" Version="4.0.2" />
<PackageVersion Include="Amazon.AspNetCore.Identity.Cognito" Version="4.0.2" />Directory.Packages.props
<PackageReference Include="Amazon.AspNetCore.Identity.Cognito" />Project file
paket add Amazon.AspNetCore.Identity.Cognito --version 4.0.2
#r "nuget: Amazon.AspNetCore.Identity.Cognito, 4.0.2"
#:package Amazon.AspNetCore.Identity.Cognito@4.0.2
#addin nuget:?package=Amazon.AspNetCore.Identity.Cognito&version=4.0.2Install as a Cake Addin
#tool nuget:?package=Amazon.AspNetCore.Identity.Cognito&version=4.0.2Install as a Cake Tool
ASP.NET Core Identity Provider for Amazon Cognito simplifies using Amazon Cognito as a membership storage solution for building ASP.NET Core web applications using ASP.NET Core Identity.
This library is not compatible with older versions of Identity such as the ones for ASP.NET MVC5 and lower. It only supports ASP.NET Core Identity and targets the .NET Standard 2.0.
The library introduces the following dependencies:
Follow the examples below to see how the library can be integrated into your web application.
This library extends the ASP.NET Core Identity membership system by using Amazon Cognito as a Custom Storage Provider for ASP.NET Identity.
Simply add the following NuGet dependencies to your ASP.NET Core application:
To add Amazon Cognito as an Identity Provider, make the following change to your code:
Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
// Adds Amazon Cognito as Identity Provider
services.AddCognitoIdentity();
...
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// If not already enabled, you will need to enable ASP.NET Core authentication
app.UseAuthentication();
...
}
Next the user pool and user pool client need to be configured as part of the IConfiguration of the ASP.NET Core application. For a development user pool edit either the appsettings.Development.json file or the projects secrets.json file. Below is an example of the JSON snippet to go into the file.
"AWS": {
"Region": "<your region id goes here>",
"UserPoolClientId": "<your user pool client id goes here>",
"UserPoolClientSecret": "<your user pool client secret goes here>",
"UserPoolId": "<your user pool id goes here>"
}
Note: If using appsettings.Development.json or some other file in your project structure be careful checking in secrets to source control.
For a production user pool it is recommend to configure the same settings as above either through IConfiguration's environment variable support or with the AWS System Manager's parameter store which can be integrated with IConfiguration using the Amazon.Extensions.Configuration.SystemsManager NuGet package.
Alternatively, instead of relying on a configuration file, you can inject your own instances of IAmazonCognitoIdentityProvider and CognitoUserPool in your Startup.cs file.
public void ConfigureServices(IServiceCollection services)
{
...
// Adds your own instance of Amazon Cognito clients
// cognitoIdentityProvider and cognitoUserPool are variables you would have instanciated yourself
services.AddSingleton<IAmazonCognitoIdentityProvider>(cognitoIdentityProvider);
services.AddSingleton<CognitoUserPool>(cognitoUserPool);
// Adds Amazon Cognito as Identity Provider
services.AddCognitoIdentity();
...
}
Once Amazon Cognito is added as the default ASP.NET Core Identity Provider, you need to use the newly introduced CognitoUser class instead of the default ApplicationUser class.
These changes will be required in existing Razor views and controllers. Here is an example with a Razor view:
@using Microsoft.AspNetCore.Identity
@using Amazon.Extensions.CognitoAuthentication
@inject SignInManager<CognitoUser> SignInManager
@inject UserManager<CognitoUser> UserManager
In addition, this library introduces two child classes of SigninManager and UserManager designed for Amazon Cognito authentication and user management workflow: CognitoSigninManager and CognitoUserManager classes.
These two classes expose additional methods designed to support Amazon Cognito features, such as sending validation data to pre-signup AWS Lambda triggers when registering a new user:
/// <summary>
/// Creates the specified <paramref name="user"/> in Cognito with the given password and validation data,
/// as an asynchronous operation.
/// </summary>
/// <param name="user">The user to create.</param>
/// <param name="password">The password for the user</param>
/// <param name="validationData">The validation data to be sent to the pre sign-up lambda triggers.</param>
/// <returns>
/// The <see cref="Task"/> that represents the asynchronous operation, containing the <see cref="IdentityResult"/>
/// of the operation.
/// </returns>
public async Task<IdentityResult> CreateAsync(TUser user, string password, IDictionary<string, string> validationData)
Feel free to explore the documentation folder and the sample application. These two resources provide additionnal examples on how to use the library with your ASP.NET Core web application.
We use the GitHub issues for tracking bugs and feature requests and have limited bandwidth to address them.
If you think you may have found a bug, please open an issue
We welcome community contributions and pull requests. See for information on how to set up a development environment and submit code.
AWS .NET GitHub Home Page
GitHub home for .NET development on AWS. You'll find libraries, tools, and resources to help you build .NET applications and services on AWS.
AWS Developer Center - Explore .NET on AWS
Find all the .NET code samples, step-by-step guides, videos, blog content, tools, and information about live events that you need in one place.
AWS Developer Blog - .NET
Come see what .NET developers at AWS are up to! Learn about new .NET software announcements, guides, and how-to's.
@dotnetonaws
Follow us on twitter!
Libraries in this repository are licensed under the Apache 2.0 License.
See and for more information.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 is compatible. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Amazon.AspNetCore.Identity.Cognito:
| Package | Downloads |
|---|---|
|
FenixAlliance.ACL.Dependencies
Application Component for the Alliance Business Suite. |
|
|
Bisque.Aws
Tool to generate AWS CloudFormation json templates for Amazon AWS CloudFormation |
|
|
gomake-common-library
Package Description |
|
|
DataManagmentSystem.Auth.Injector
Package Description |
|
|
LonginesIDProvider
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.2 | 62,771 | 3/13/2026 |
| 4.0.1 | 155,694 | 11/17/2025 |
| 4.0.0 | 248,748 | 4/28/2025 |
| 4.0.0-preview.3 | 284 | 4/2/2025 |
| 4.0.0-preview.2 | 317 | 3/3/2025 |
| 4.0.0-preview.1 | 3,281 | 10/22/2024 |
| 3.0.3 | 60,185 | 4/23/2025 |
| 3.0.2 | 824,612 | 4/20/2024 |
| 3.0.1 | 1,081,483 | 2/10/2023 |
| 3.0.0 | 1,750,671 | 7/6/2021 |
| 2.2.0 | 147,777 | 3/31/2021 |
| 2.1.0 | 14,044 | 3/22/2021 |
| 2.0.3 | 24,081 | 2/12/2021 |
| 2.0.2 | 63,941 | 1/8/2021 |
| 2.0.1 | 5,954 | 12/28/2020 |
| 2.0.0 | 3,213 | 12/22/2020 |
| 1.0.5 | 265,475 | 6/30/2020 |
| 1.0.4 | 205,210 | 1/17/2020 |
| 1.0.3 | 47,118 | 11/22/2019 |
| 1.0.2 | 52,730 | 8/13/2019 |