AdminBro feature allowing you to hash passwords in a a given resource.


To install the passwords feature run:

yarn add @admin-bro/passwords

And install password hashing library if you don't have it yet. I suggest using argon2 or Bcrypt..

yarn add argon2

You can also implement your own hashing function.


As any feature, you have to pass it to the resource in AdminBroOptions#resources.

In the example below we will use argon2 as a hashing function. We will also use encrypted property from the User model, where we will store the hashed password.

Furthermore, we will hide the encrypted field in the UI. We will do this by the help of the standard PropertyOptions#isVisible

Feature creates virtual password property. You can change that in PasswordsOptions.

const AdminBro = require('admin-bro')
const passwordFeature = require('@admin-bro/passwords')
const argon2 = require('argon2')

// part where you load adapter and models
const User = require('./user')

const options = {
  resources: [{
    resource: User,
    options: {
      properties: { encrypted: { isVisible: false } },
    features: [passwordFeature({
      // PasswordsOptions
      properties: {
        // to this field will save the hashed password
        encryptedPassword: 'encrypted'
      hash: argon2.hash,

const adminBro = new AdminBro(options)
// and the rest of your app


For the lits of available options take see at PasswordsOptions.

Type Definitions

# HashingFunction(password) → {Promise.<string>|string}

Hashing function used to convert the password

Name Type Description
password string

Password which should be hashed

View Source admin-bro-passwords/src/passwords.feature.ts, line 61

Promise.<string> | string

# PasswordsOptions

Options passed to PasswordsFeature

Name Type Attributes Description
properties object <optional>

Names of the properties used by the feature

password string <optional>

Virtual property which will be seen by end user. Its value is not stored in the database., Default to password

encryptedPassword string <optional>

Property where encrypted password will be stored. Default to encryptedPassword

hash HashingFunction

Function used to hash the password. You can pass function from the external library, Example using Argon2.: hash: argon2.hash

View Source admin-bro-passwords/src/passwords.feature.ts, line 70


Proudly built and maintained by SoftwareBrothers

Software House with a passion for both JavaScript and TypeScript.

See what we do See what we believe in

Proudly built and maintained by