An ASP.NET Core Identity 8.0 provider for DynamoDB.
You can install the latest version via Nuget:
> dotnet add package AspNetCore.Identity.AmazonDynamoDB
Then you use the stores by calling AddDynamoDbStores
on IdentityBuilder
:
services
.AddIdentityCore<DynamoDbUser>()
.AddRoles<DynamoDbRole>()
.AddDynamoDbStores()
.Configure(options =>
{
options.BillingMode = BillingMode.PROVISIONED; // Default is BillingMode.PAY_PER_REQUEST
options.ProvisionedThroughput = new ProvisionedThroughput
{
ReadCapacityUnits = 5, // Default is 1
WriteCapacityUnits = 5, // Default is 1
};
options.DefaultTableName = "my-custom-identity-table-name"; // Default is identity
});
Finally, you need to ensure that tables and indexes have been added:
AspNetCoreIdentityDynamoDbSetup.EnsureInitialized(serviceProvider);
Or asynchronously:
await AspNetCoreIdentityDynamoDbSetup.EnsureInitializedAsync(serviceProvider);
To run the tests, you need to have DynamoDB running locally on localhost:8000
. This can easily be done using Docker and the following command:
docker run -p 8000:8000 amazon/dynamodb-local
To add custom attributes to the user or role model, you would need to create a new class that extends the DynamoDbUser
or DynamoDbRole
and adds the needed additional attributes.
public class CustomUser : DynamoDbUser
{
public string? ProfilePictureUrl { get; set; }
}
Then you need to use your new classes when adding the DynamoDB stores:
services
.AddIdentityCore<CustomUser>()
.AddRoles<CustomRole>()
.AddDynamoDbStores();