Amplication’s Authentication Entity provides a standardized, pre-configured foundation for user management and security in your resources. It’s required if you want to add authentication to your resource.

By default, Amplication uses a User entity as the Authentication entity. When you enable an authentication plugin, Amplication automatically creates this User entity (or prompts you to create it) with all the necessary fields. You can also use your own custom entity, as long as it includes the required fields.

Why is the Authentication Entity Required?

Authentication plugins in Amplication, such as the NestJS Auth Module for Node.js Blueprints and ASP.NET Core Identity for .NET Blueprints, rely on a properly defined Authentication entity. The plugins use this entity to manage user logins, permissions, and overall security. Without a correctly configured Authentication entity, authentication plugins won’t work.

Essentially, the Authentication entity provides a:

Standardized User Model

You get a consistent structure for user data across all your Amplication services.

Simplified Setup

Amplication handles the core plumbing, so you don’t have to write authentication boilerplate from scratch.

Plugin Compatibility

It’s the bedrock for Amplication’s authentication plugins, guaranteeing seamless integration.

Change the Default Authentication Entity

You have the flexibility to designate a different entity as your Authentication entity if the default User entity doesn’t perfectly fit your data model.

1

Go to Resource Settings

Navigate to your resource’s Settings tab.

2

Access Authentication Entity Settings

Find and click on the Authentication Entity settings in the left side bar.

3

Select New Entity

Use the Entity List dropdown to choose the entity you want to use as your new Authentication entity.

You’ve now successfully changed the default Authentication entity for your service.

Each Authentication plugin may require different fields for proper functionality. If the required fields are missing, your authentication plugins will not function correctly. You may find a detailed message in the build log. See the Plugin settings page, or the plugin documentation for more details.

Add Default User Entity

1

Navigate to Entities

Go to Entities tab in your Amplication resource.

2

Create New Entity

Click Add Entity ➔ Name it User ➔ Click Create Entity

3

Restore Default Fields

Confirm restoration of default fields when prompted

For Node.js resources: Add this before enabling NestJS Auth Module. For .NET: Create before ASP.NET Core Identity setup.

Required Fields

To work smoothly with authentication plugins, your Authentication entity needs specific fields.

FieldRequiredUniqueDescription
idYesYesAuto-generated unique identifier
createdAtYesNoAutomatic timestamp on creation
updatedAtYesNoAutomatic timestamp on modification
usernameYesYesLogin identifier (searchable)
emailYesYesUser’s email address (searchable)
passwordYesNoSecurely hashed credentials
rolesYesNoPermission group assignments
firstNameNoNoUser’s first name (searchable)
lastNameNoNoUser’s last name (searchable)

These default fields are designed to cover the most common authentication scenarios. They give you a robust starting point for user management and security.

If you use the default User entity, Amplication automatically sets these up for you.

Delete the Authentication Entity

While you can typically delete any entity you create in Amplication, the Authentication entity is a bit different because of its central role in security. To delete the Authentication entity, you must first disable all authentication plugins in your service.

This means disabling:

  • NestJS Auth Module (and any other authentication plugins) for resources based on the Node.js blueprint.
  • ASP.NET Core Identity plugin for resources based on the .NET blueprint.
1

Disable Authentication Plugin

Go to your service’s Plugins page. Disable the authentication plugin(s) for your service type.

  • Node.js: Toggle the NestJS Auth Module to the “off” position. Disable any other authentication plugins you may have installed.
  • .NET: Disable the ASP.NET Core Identity plugin.
2

Navigate to Entities

Go to your service’s Entities page.

3

Delete Entity

You’ll now see that the delete button for the Authentication entity is enabled. Click the delete button next to the Authentication entity. A confirmation popup will appear.

The Authentication entity is now removed from your resource. You’ll have to re-enable your authentication plugin and potentially recreate the Authentication entity if you need authentication again in the future.